core structure updates

This commit is contained in:
Rory Powell 2023-07-14 11:44:05 +01:00
parent 8cdfc8dd83
commit 1964148581
6 changed files with 22 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { structures } from ".." import { generator } from "./generator"
import { newid } from "../../../../src/docIds/newid" import { newid } from "../../../../src/docIds/newid"
export function id() { export function id() {
@ -6,7 +6,7 @@ export function id() {
} }
export function rev() { export function rev() {
return `${structures.generator.character({ return `${generator.character({
numeric: true, numeric: true,
})}-${structures.uuid().replace(/-/, "")}` })}-${generator.guid().replace(/-/, "")}`
} }

View File

@ -0,0 +1 @@
export * from "./platform"

View File

@ -0,0 +1 @@
export * as installation from "./installation"

View File

@ -1,9 +1,11 @@
import { generator } from "@budibase/backend-core/tests" import { generator } from "@budibase/backend-core/tests"
import { Installation } from "@budibase/types" import { Installation } from "@budibase/types"
import * as db from "../../db"
export function install(): Installation { export function install(): Installation {
return { return {
_id: "install", _id: "install",
_rev: db.rev(),
installId: generator.guid(), installId: generator.guid(),
version: generator.string() version: generator.string()
} }

View File

@ -2,7 +2,7 @@ export * from "./common"
export * as accounts from "./accounts" export * as accounts from "./accounts"
export * as apps from "./apps" export * as apps from "./apps"
export * as db from "./db" export * as db from "./db"
export * as installation from "./installation" export * as docs from "./documents"
export * as koa from "./koa" export * as koa from "./koa"
export * as licenses from "./licenses" export * as licenses from "./licenses"
export * as plugins from "./plugins" export * as plugins from "./plugins"

View File

@ -2,7 +2,9 @@ import {
Billing, Billing,
Customer, Customer,
Feature, Feature,
License, OfflineLicense, License,
OfflineIdentifier,
OfflineLicense,
PlanModel, PlanModel,
PlanType, PlanType,
PriceDuration, PriceDuration,
@ -154,9 +156,16 @@ export function offlineLicense (
return { return {
...base, ...base,
expireAt: new Date().toISOString(), expireAt: new Date().toISOString(),
identifier: { identifier: offlineIdentifier()
installId: generator.guid(), }
tenantId: generator.guid() }
}
export function offlineIdentifier(
installId: string = generator.guid(),
tenantId: string = generator.guid(),
): OfflineIdentifier {
return {
installId,
tenantId
} }
} }