@tailor-platform/sdk 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +171 -0
- package/README.md +1 -1
- package/dist/aigateway-DsWDjzk4.mjs +2 -0
- package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
- package/dist/application-DFOUovmN.mjs +1 -0
- package/dist/application-D_4vg1KR.mjs +192 -0
- package/dist/application-D_4vg1KR.mjs.map +1 -0
- package/dist/assert-WeXvmG4j.mjs +2 -0
- package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
- package/dist/authconnection-CynFBIv8.mjs +2 -0
- package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
- package/dist/brand-C8nMKhJC.mjs +2 -0
- package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
- package/dist/cli/commands/deploy/deploy.d.mts +2 -2
- package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
- package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
- package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
- package/dist/cli/commands/executor/jobs.d.mts +1 -1
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
- package/dist/cli/commands/show.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +15 -15
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +7 -3
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
- package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
- package/dist/cli/lib.d.mts +8 -4
- package/dist/cli/lib.mjs +1 -9
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +1170 -7686
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/seed-chunker.d.mts +5 -5
- package/dist/cli/ts-hook.mjs +3 -1
- package/dist/completion/zsh-worker.zsh +99 -18
- package/dist/configure/config/index.d.mts +2 -2
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +49 -12
- package/dist/configure/index.mjs +1 -1267
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +5 -4
- package/dist/configure/services/aigateway/types.d.mts +6 -1
- package/dist/configure/services/auth/types.d.mts +3 -3
- package/dist/configure/services/idp/types.d.mts +1 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +5 -9
- package/dist/configure/services/tailordb/types.d.mts +8 -5
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/job.d.mts +12 -2
- package/dist/configure/types/auth-namespace-name.d.mts +18 -0
- package/dist/configure/types/field.types.d.mts +1 -1
- package/dist/configure/types/permission-operand.types.d.mts +1 -1
- package/dist/context-D0QjfxzD.mjs +2 -0
- package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
- package/dist/crashreport-B-_HTKLr.mjs +42 -0
- package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
- package/dist/crashreport-BmsRIdpy.mjs +1 -0
- package/dist/errors-DSEXKRVD.mjs +2 -0
- package/dist/errors-DSEXKRVD.mjs.map +1 -0
- package/dist/file-COPYfju_.mjs +2 -0
- package/dist/file-COPYfju_.mjs.map +1 -0
- package/dist/globals-CMHSnj4w.mjs +2 -0
- package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
- package/dist/iconv-DlFMt2gW.mjs +2 -0
- package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
- package/dist/idp-G_ojPBB5.mjs +2 -0
- package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
- package/dist/interceptor-DQg3cR_9.mjs +2 -0
- package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
- package/dist/kysely/index.mjs +1 -31
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/kysely-type-BTi3BMtL.mjs +43 -0
- package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
- package/dist/logger-BcGy-u7G.mjs +9 -0
- package/dist/{logger-DSdExfor.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
- package/dist/logger-DP2BjQ93.mjs +2 -0
- package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
- package/dist/multiline-EyzjEwn9.mjs +3 -0
- package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
- package/dist/node-builtins-oBl7EbyV.mjs +2 -0
- package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
- package/dist/package-json-C690ceex.mjs +2 -0
- package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
- package/dist/package-json-CmqhDJ__.mjs +1 -0
- package/dist/parser/service/tailordb/type-source.d.mts +5 -5
- package/dist/parser/service/tailordb/types.d.mts +4 -4
- package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
- package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +22 -101
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +9 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
- package/dist/plugin/builtin/seed/index.d.mts +5 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -3
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -6
- package/dist/plugin/get-generated-table.d.mts +16 -0
- package/dist/plugin/index.d.mts +3 -2
- package/dist/plugin/index.mjs +1 -251
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +32 -25
- package/dist/plugin/with-context.d.mts +4 -4
- package/dist/register-ts-hook-Drnaproy.mjs +640 -0
- package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
- package/dist/registry-HlEaGvl5.mjs +2 -0
- package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
- package/dist/repl-editor-BG1aDOfH.mjs +2 -0
- package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
- package/dist/runtime/aigateway.mjs +1 -3
- package/dist/runtime/authconnection.mjs +1 -3
- package/dist/runtime/context.mjs +1 -3
- package/dist/runtime/file.d.mts +28 -28
- package/dist/runtime/file.mjs +1 -3
- package/dist/runtime/globals.mjs +1 -1
- package/dist/runtime/iconv.mjs +1 -3
- package/dist/runtime/idp.mjs +1 -3
- package/dist/runtime/index.mjs +1 -11
- package/dist/runtime/logger.mjs +1 -3
- package/dist/runtime/secretmanager.mjs +1 -3
- package/dist/runtime/types.d.mts +1 -1
- package/dist/runtime/workflow.mjs +1 -3
- package/dist/schema-Ze_dI5VX.mjs +2 -0
- package/dist/schema-Ze_dI5VX.mjs.map +1 -0
- package/dist/secret-file-C9wp_FCX.mjs +2 -0
- package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
- package/dist/secretmanager-5olfnI1b.mjs +2 -0
- package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
- package/dist/secretmanager-vHQoXdQz.mjs +2 -0
- package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
- package/dist/seed/index.d.mts +4 -4
- package/dist/seed/index.mjs +8 -244
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-DwqRFdqP.mjs +207 -0
- package/dist/seed-DwqRFdqP.mjs.map +1 -0
- package/dist/service-BVe9u2Rt.mjs +7 -0
- package/dist/service-BVe9u2Rt.mjs.map +1 -0
- package/dist/service-CpZELSBa.mjs +1 -0
- package/dist/service-DlgaUO4V.mjs +2 -0
- package/dist/{service-hZskxZmg.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
- package/dist/service_pb-DGKCLuAs.mjs +2 -0
- package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
- package/dist/service_pb-_aeFE-Nv.mjs +1 -0
- package/dist/telemetry-Bklv9kQY.mjs +2 -0
- package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
- package/dist/telemetry-DXHP3VVi.mjs +1 -0
- package/dist/type-source--ZNcV8RJ.mjs +2 -0
- package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
- package/dist/types/aigateway.generated.d.mts +2 -2
- package/dist/types/auth.generated.d.mts +3 -3
- package/dist/types/executor.generated.d.mts +2 -2
- package/dist/types/tailordb.generated.d.mts +12 -12
- package/dist/user-agent-vdHYF3QL.mjs +2 -0
- package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +1 -109
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -41
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs +1 -1980
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/file.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -140
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
- package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
- package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
- package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
- package/dist/workflow-Cs9ISw6j.mjs +2 -0
- package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
- package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
- package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
- package/docs/cli/application.md +3 -1
- package/docs/cli/function.md +77 -13
- package/docs/cli/setup.md +24 -14
- package/docs/cli/tailordb.md +32 -30
- package/docs/cli/workspace.md +2 -2
- package/docs/cli-reference.md +23 -22
- package/docs/configuration.md +2 -2
- package/docs/github-actions.md +10 -9
- package/docs/migration/v2.md +16 -4
- package/docs/migration/v3.md +123 -0
- package/docs/plugin/custom.md +130 -85
- package/docs/plugin/index.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/services/aigateway.md +33 -9
- package/docs/services/executor.md +5 -1
- package/docs/services/tailordb-migration.md +68 -54
- package/docs/services/tailordb.md +7 -7
- package/docs/services/workflow.md +10 -9
- package/docs/testing.md +1 -1
- package/package.json +16 -16
- package/postinstall.mjs +1 -1
- package/dist/aigateway-DR4Kwuik.mjs +0 -9
- package/dist/application-BZfk4HKm.mjs +0 -3
- package/dist/application-F-nl107y.mjs +0 -6019
- package/dist/application-F-nl107y.mjs.map +0 -1
- package/dist/assert-DBxo8jPo.mjs +0 -9
- package/dist/authconnection-CZvi9ANm.mjs +0 -9
- package/dist/brand-Eo4pLXPJ.mjs +0 -36
- package/dist/context-DYQVYWqZ.mjs +0 -23
- package/dist/crashreport-CIIfLnoO.mjs +0 -423
- package/dist/crashreport-CINZ5dVN.mjs +0 -3
- package/dist/errors-BVb6vYGy.mjs +0 -89
- package/dist/errors-BVb6vYGy.mjs.map +0 -1
- package/dist/file-BUcmVIH2.mjs +0 -58
- package/dist/file-BUcmVIH2.mjs.map +0 -1
- package/dist/globals-B2nlxBrz.mjs +0 -126
- package/dist/iconv-QWaZh0TT.mjs +0 -38
- package/dist/idp-RA_swu-h.mjs +0 -82
- package/dist/interceptor-e33JtsC-.mjs +0 -33
- package/dist/logger-BtX0suGY.mjs +0 -48
- package/dist/logger-DSdExfor.mjs +0 -358
- package/dist/multiline-sfHpTZZK.mjs +0 -38
- package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
- package/dist/package-json-8b0O9TlX.mjs +0 -17
- package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
- package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
- package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
- package/dist/plugin/builtin/seed/types.d.mts +0 -2
- package/dist/plugin/get-generated-type.d.mts +0 -16
- package/dist/register-ts-hook-ClI226n2.mjs +0 -25543
- package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
- package/dist/registry-BIGVUrMB.mjs +0 -54
- package/dist/repl-editor-BCozyiNq.mjs +0 -251
- package/dist/schema--xYWRGfe.mjs +0 -639
- package/dist/schema--xYWRGfe.mjs.map +0 -1
- package/dist/secret-file-C3J4Gy8r.mjs +0 -64
- package/dist/secretmanager-CYlpffsz.mjs +0 -13
- package/dist/secretmanager-IY4UvinW.mjs +0 -131
- package/dist/seed-xqM9WIHP.mjs +0 -483
- package/dist/seed-xqM9WIHP.mjs.map +0 -1
- package/dist/service-C_WpbKHu.mjs +0 -898
- package/dist/service-C_WpbKHu.mjs.map +0 -1
- package/dist/service-D1RCdzIL.mjs +0 -3
- package/dist/service-hZskxZmg.mjs +0 -131
- package/dist/service_pb-BEWj1pOV.mjs +0 -167
- package/dist/service_pb-BjlhvK9E.mjs +0 -3
- package/dist/telemetry-BRVdwh14.mjs +0 -84
- package/dist/telemetry-CkbkeJxl.mjs +0 -3
- package/dist/type-source-DH_LH20p.mjs +0 -13
- package/dist/type-source-DH_LH20p.mjs.map +0 -1
- package/dist/user-agent-Bgsszb5I.mjs +0 -28
- package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
- package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
- package/dist/wait-point-registry-TL99zotw.mjs +0 -47
- package/dist/workflow-Bamae_Yc.mjs +0 -34
- package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
package/dist/schema--xYWRGfe.mjs
DELETED
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
import { t as brandValue } from "./brand-Eo4pLXPJ.mjs";
|
|
2
|
-
import { cloneDeep } from "es-toolkit";
|
|
3
|
-
|
|
4
|
-
//#region src/runtime/field-parse.ts
|
|
5
|
-
const regex = {
|
|
6
|
-
uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
7
|
-
date: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/,
|
|
8
|
-
time: /^(?<hour>[01]\d|2[0-3]):(?<minute>[0-5]\d)$/,
|
|
9
|
-
datetime: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})[Tt](?<hour>[01]\d|2[0-3]):(?<minute>[0-5]\d):(?<second>[0-5]\d|60)(\.(?<fraction>\d+))?(?<offset>[Zz]|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/,
|
|
10
|
-
decimal: /^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/
|
|
11
|
-
};
|
|
12
|
-
function validateBaseValue(args) {
|
|
13
|
-
const { field, value, pathArray, issues } = args;
|
|
14
|
-
const path = pathArray.length > 0 ? pathArray : void 0;
|
|
15
|
-
const initialIssueCount = issues.length;
|
|
16
|
-
switch (field.type) {
|
|
17
|
-
case "string":
|
|
18
|
-
if (typeof value !== "string") issues.push({
|
|
19
|
-
message: `Expected a string: received ${String(value)}`,
|
|
20
|
-
path
|
|
21
|
-
});
|
|
22
|
-
break;
|
|
23
|
-
case "integer":
|
|
24
|
-
if (typeof value !== "number" || !Number.isInteger(value)) issues.push({
|
|
25
|
-
message: `Expected an integer: received ${String(value)}`,
|
|
26
|
-
path
|
|
27
|
-
});
|
|
28
|
-
break;
|
|
29
|
-
case "float":
|
|
30
|
-
if (typeof value !== "number" || !Number.isFinite(value)) issues.push({
|
|
31
|
-
message: `Expected a number: received ${String(value)}`,
|
|
32
|
-
path
|
|
33
|
-
});
|
|
34
|
-
break;
|
|
35
|
-
case "boolean":
|
|
36
|
-
if (typeof value !== "boolean") issues.push({
|
|
37
|
-
message: `Expected a boolean: received ${String(value)}`,
|
|
38
|
-
path
|
|
39
|
-
});
|
|
40
|
-
break;
|
|
41
|
-
case "uuid":
|
|
42
|
-
if (typeof value !== "string" || !regex.uuid.test(value)) issues.push({
|
|
43
|
-
message: `Expected a valid UUID: received ${String(value)}`,
|
|
44
|
-
path
|
|
45
|
-
});
|
|
46
|
-
break;
|
|
47
|
-
case "date":
|
|
48
|
-
if (typeof value !== "string" || !regex.date.test(value)) issues.push({
|
|
49
|
-
message: `Expected to match "yyyy-MM-dd" format: received ${String(value)}`,
|
|
50
|
-
path
|
|
51
|
-
});
|
|
52
|
-
break;
|
|
53
|
-
case "datetime":
|
|
54
|
-
if (typeof value !== "string" || !regex.datetime.test(value)) issues.push({
|
|
55
|
-
message: `Expected to match ISO format: received ${String(value)}`,
|
|
56
|
-
path
|
|
57
|
-
});
|
|
58
|
-
break;
|
|
59
|
-
case "time":
|
|
60
|
-
if (typeof value !== "string" || !regex.time.test(value)) issues.push({
|
|
61
|
-
message: `Expected to match "HH:mm" format: received ${String(value)}`,
|
|
62
|
-
path
|
|
63
|
-
});
|
|
64
|
-
break;
|
|
65
|
-
case "decimal":
|
|
66
|
-
if (typeof value !== "string" || !regex.decimal.test(value)) issues.push({
|
|
67
|
-
message: `Expected a decimal string: received ${String(value)}`,
|
|
68
|
-
path
|
|
69
|
-
});
|
|
70
|
-
break;
|
|
71
|
-
case "enum":
|
|
72
|
-
if (field._metadata.allowedValues) {
|
|
73
|
-
const allowedValues = field._metadata.allowedValues.map((v) => v.value);
|
|
74
|
-
if (typeof value !== "string" || !allowedValues.includes(value)) issues.push({
|
|
75
|
-
message: `Must be one of [${allowedValues.join(", ")}]: received ${String(value)}`,
|
|
76
|
-
path
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
case "nested": {
|
|
81
|
-
if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Date) {
|
|
82
|
-
issues.push({
|
|
83
|
-
message: `Expected an object: received ${String(value)}`,
|
|
84
|
-
path
|
|
85
|
-
});
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
let nestedBaseValid = true;
|
|
89
|
-
for (const [fieldName, nestedField] of Object.entries(field.fields)) {
|
|
90
|
-
const fieldValue = value[fieldName];
|
|
91
|
-
if (!validateBaseField({
|
|
92
|
-
...args,
|
|
93
|
-
field: nestedField,
|
|
94
|
-
value: fieldValue,
|
|
95
|
-
pathArray: pathArray.concat(fieldName)
|
|
96
|
-
})) nestedBaseValid = false;
|
|
97
|
-
}
|
|
98
|
-
return nestedBaseValid;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return issues.length === initialIssueCount;
|
|
102
|
-
}
|
|
103
|
-
function validateCustomValue(args, validateFns) {
|
|
104
|
-
const { value, pathArray, issues } = args;
|
|
105
|
-
const path = pathArray.length > 0 ? pathArray : void 0;
|
|
106
|
-
for (const fn of validateFns) {
|
|
107
|
-
const result = fn({ value });
|
|
108
|
-
if (typeof result === "string") issues.push({
|
|
109
|
-
message: result,
|
|
110
|
-
path
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function validateBaseField(args) {
|
|
115
|
-
const { field, value, pathArray, issues } = args;
|
|
116
|
-
const path = pathArray.length > 0 ? pathArray : void 0;
|
|
117
|
-
const isNullOrUndefined = value === null || value === void 0;
|
|
118
|
-
if (field._metadata.required && isNullOrUndefined) {
|
|
119
|
-
issues.push({
|
|
120
|
-
message: "Required field is missing",
|
|
121
|
-
path
|
|
122
|
-
});
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
if (!field._metadata.required && isNullOrUndefined) return true;
|
|
126
|
-
let baseValid = true;
|
|
127
|
-
if (field._metadata.array) {
|
|
128
|
-
if (!Array.isArray(value)) {
|
|
129
|
-
issues.push({
|
|
130
|
-
message: "Expected an array",
|
|
131
|
-
path
|
|
132
|
-
});
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
for (let i = 0; i < value.length; i++) if (!validateBaseValue({
|
|
136
|
-
...args,
|
|
137
|
-
value: value[i],
|
|
138
|
-
pathArray: pathArray.concat(`[${i}]`)
|
|
139
|
-
})) baseValid = false;
|
|
140
|
-
} else baseValid = validateBaseValue(args);
|
|
141
|
-
return baseValid;
|
|
142
|
-
}
|
|
143
|
-
function validateCustomField(args) {
|
|
144
|
-
const { field, value, pathArray } = args;
|
|
145
|
-
if (value === null || value === void 0) return;
|
|
146
|
-
if (field.type === "nested") {
|
|
147
|
-
const records = field._metadata.array ? value : [value];
|
|
148
|
-
for (let i = 0; i < records.length; i++) {
|
|
149
|
-
const record = records[i];
|
|
150
|
-
const recordPath = field._metadata.array ? pathArray.concat(`[${i}]`) : pathArray;
|
|
151
|
-
for (const [fieldName, nestedField] of Object.entries(field.fields)) validateCustomField({
|
|
152
|
-
...args,
|
|
153
|
-
field: nestedField,
|
|
154
|
-
value: record[fieldName],
|
|
155
|
-
pathArray: recordPath.concat(fieldName)
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const validateFns = field._metadata.validate;
|
|
160
|
-
if (validateFns?.length) validateCustomValue(args, validateFns);
|
|
161
|
-
}
|
|
162
|
-
function parseInternal(args) {
|
|
163
|
-
const { value } = args;
|
|
164
|
-
const issues = [];
|
|
165
|
-
const validationArgs = {
|
|
166
|
-
...args,
|
|
167
|
-
issues
|
|
168
|
-
};
|
|
169
|
-
if (validateBaseField(validationArgs)) validateCustomField(validationArgs);
|
|
170
|
-
if (issues.length > 0) return { issues };
|
|
171
|
-
return { value: value ?? null };
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Validate a value against a record of input fields, treating the record as a
|
|
175
|
-
* single required object — the same code path deployed functions run via
|
|
176
|
-
* `t.object(fields).parse(...)`, so local validation matches platform behavior.
|
|
177
|
-
* @param args - Input field definitions plus the value, context data, and user
|
|
178
|
-
* @returns Validation result
|
|
179
|
-
*/
|
|
180
|
-
function parseInputFields(args) {
|
|
181
|
-
const { fields, ...parseArgs } = args;
|
|
182
|
-
return parseInternal({
|
|
183
|
-
...parseArgs,
|
|
184
|
-
field: {
|
|
185
|
-
type: "nested",
|
|
186
|
-
fields,
|
|
187
|
-
_metadata: { required: true }
|
|
188
|
-
},
|
|
189
|
-
pathArray: []
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/configure/types/field.ts
|
|
195
|
-
/**
|
|
196
|
-
* Normalize allowed values into EnumValue objects with descriptions.
|
|
197
|
-
* @param values - Allowed values as strings or EnumValue objects
|
|
198
|
-
* @returns Normalized allowed values
|
|
199
|
-
*/
|
|
200
|
-
function mapAllowedValues(values) {
|
|
201
|
-
return values.map((value) => {
|
|
202
|
-
if (typeof value === "string") return {
|
|
203
|
-
value,
|
|
204
|
-
description: ""
|
|
205
|
-
};
|
|
206
|
-
return {
|
|
207
|
-
...value,
|
|
208
|
-
description: value.description ?? ""
|
|
209
|
-
};
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/configure/services/tailordb/schema.ts
|
|
215
|
-
function isRelationSelfConfig(config) {
|
|
216
|
-
return config.toward.type === "self";
|
|
217
|
-
}
|
|
218
|
-
function createTailorDBField(type, options, fields, values) {
|
|
219
|
-
return createTailorDBFieldRuntime(type, options, fields, values);
|
|
220
|
-
}
|
|
221
|
-
function createTailorDBFieldRuntime(type, options, fields, values) {
|
|
222
|
-
const _metadata = { required: true };
|
|
223
|
-
let _rawRelation;
|
|
224
|
-
if (options) {
|
|
225
|
-
if (options.optional === true) _metadata.required = false;
|
|
226
|
-
if (options.array === true) _metadata.array = true;
|
|
227
|
-
}
|
|
228
|
-
if (values) _metadata.allowedValues = mapAllowedValues(values);
|
|
229
|
-
function parseInternal$1(args) {
|
|
230
|
-
return parseInternal({
|
|
231
|
-
...args,
|
|
232
|
-
field
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
function cloneWith(metadataUpdates) {
|
|
236
|
-
const cloned = field.clone();
|
|
237
|
-
Object.assign(cloned._metadata, metadataUpdates);
|
|
238
|
-
return cloned;
|
|
239
|
-
}
|
|
240
|
-
const field = {
|
|
241
|
-
type,
|
|
242
|
-
fields: fields ?? {},
|
|
243
|
-
_defined: void 0,
|
|
244
|
-
_output: void 0,
|
|
245
|
-
_metadata,
|
|
246
|
-
get metadata() {
|
|
247
|
-
return { ...this._metadata };
|
|
248
|
-
},
|
|
249
|
-
get rawRelation() {
|
|
250
|
-
return _rawRelation ? {
|
|
251
|
-
..._rawRelation,
|
|
252
|
-
toward: { ..._rawRelation.toward }
|
|
253
|
-
} : void 0;
|
|
254
|
-
},
|
|
255
|
-
description(description) {
|
|
256
|
-
return cloneWith({ description });
|
|
257
|
-
},
|
|
258
|
-
typeName(typeName) {
|
|
259
|
-
return cloneWith({ typeName });
|
|
260
|
-
},
|
|
261
|
-
validate(...validateInputs) {
|
|
262
|
-
return cloneWith({ validate: validateInputs });
|
|
263
|
-
},
|
|
264
|
-
parse(args) {
|
|
265
|
-
return parseInternal$1({
|
|
266
|
-
value: args.value,
|
|
267
|
-
data: args.data,
|
|
268
|
-
invoker: args.invoker,
|
|
269
|
-
pathArray: []
|
|
270
|
-
});
|
|
271
|
-
},
|
|
272
|
-
relation(config) {
|
|
273
|
-
const cloned = field.clone();
|
|
274
|
-
const targetType = isRelationSelfConfig(config) ? "self" : config.toward.type.name;
|
|
275
|
-
cloned._setRawRelation({
|
|
276
|
-
type: config.type,
|
|
277
|
-
toward: {
|
|
278
|
-
type: targetType,
|
|
279
|
-
as: config.toward.as,
|
|
280
|
-
key: config.toward.key
|
|
281
|
-
},
|
|
282
|
-
backward: config.backward
|
|
283
|
-
});
|
|
284
|
-
return cloned;
|
|
285
|
-
},
|
|
286
|
-
index() {
|
|
287
|
-
return cloneWith({ index: true });
|
|
288
|
-
},
|
|
289
|
-
unique() {
|
|
290
|
-
return cloneWith({
|
|
291
|
-
unique: true,
|
|
292
|
-
index: true
|
|
293
|
-
});
|
|
294
|
-
},
|
|
295
|
-
vector() {
|
|
296
|
-
return cloneWith({ vector: true });
|
|
297
|
-
},
|
|
298
|
-
default(value) {
|
|
299
|
-
return cloneWith({ default: value });
|
|
300
|
-
},
|
|
301
|
-
hooks(hooks) {
|
|
302
|
-
return cloneWith({ hooks });
|
|
303
|
-
},
|
|
304
|
-
serial(config) {
|
|
305
|
-
return cloneWith({ serial: config });
|
|
306
|
-
},
|
|
307
|
-
clone(cloneOptions) {
|
|
308
|
-
if (this._metadata.validate?.length && cloneOptions?.array !== void 0 && cloneOptions.array !== (this._metadata.array === true)) throw new Error("Cannot change the array option on a field with custom validation");
|
|
309
|
-
let clonedFields = fields;
|
|
310
|
-
if (fields) {
|
|
311
|
-
const cloned = {};
|
|
312
|
-
for (const [key, field] of Object.entries(fields)) cloned[key] = field.clone();
|
|
313
|
-
clonedFields = cloned;
|
|
314
|
-
}
|
|
315
|
-
const clonedField = createTailorDBFieldRuntime(type, options, clonedFields, values);
|
|
316
|
-
Object.assign(clonedField._metadata, cloneDeep(this._metadata));
|
|
317
|
-
if (cloneOptions) {
|
|
318
|
-
if (cloneOptions.optional !== void 0) clonedField._metadata.required = !cloneOptions.optional;
|
|
319
|
-
if (cloneOptions.array !== void 0) clonedField._metadata.array = cloneOptions.array;
|
|
320
|
-
}
|
|
321
|
-
if (_rawRelation) clonedField._setRawRelation(cloneDeep(_rawRelation));
|
|
322
|
-
return clonedField;
|
|
323
|
-
},
|
|
324
|
-
_setRawRelation(relation) {
|
|
325
|
-
_rawRelation = relation;
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
return field;
|
|
329
|
-
}
|
|
330
|
-
const createField = createTailorDBField;
|
|
331
|
-
/**
|
|
332
|
-
* Create a UUID field.
|
|
333
|
-
* @param options - Field configuration options
|
|
334
|
-
* @returns A UUID field
|
|
335
|
-
* @example db.uuid()
|
|
336
|
-
* @example db.uuid({ optional: true })
|
|
337
|
-
*/
|
|
338
|
-
function uuid(options) {
|
|
339
|
-
return createField("uuid", options);
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Create a string field.
|
|
343
|
-
* @param options - Field configuration options
|
|
344
|
-
* @returns A string field
|
|
345
|
-
* @example db.string()
|
|
346
|
-
* @example db.string({ optional: true })
|
|
347
|
-
*/
|
|
348
|
-
function string(options) {
|
|
349
|
-
return createField("string", options);
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Create a boolean field.
|
|
353
|
-
* Note: The method name is `bool` but creates a `boolean` type field.
|
|
354
|
-
* @param options - Field configuration options
|
|
355
|
-
* @returns A boolean field
|
|
356
|
-
* @example db.bool()
|
|
357
|
-
* @example db.bool({ optional: true })
|
|
358
|
-
*/
|
|
359
|
-
function bool(options) {
|
|
360
|
-
return createField("boolean", options);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Create an integer field.
|
|
364
|
-
* @param options - Field configuration options
|
|
365
|
-
* @returns An integer field
|
|
366
|
-
* @example db.int()
|
|
367
|
-
* @example db.int({ optional: true })
|
|
368
|
-
*/
|
|
369
|
-
function int(options) {
|
|
370
|
-
return createField("integer", options);
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Create a float (decimal number) field.
|
|
374
|
-
* @param options - Field configuration options
|
|
375
|
-
* @returns A float field
|
|
376
|
-
* @example db.float()
|
|
377
|
-
* @example db.float({ optional: true })
|
|
378
|
-
*/
|
|
379
|
-
function float(options) {
|
|
380
|
-
return createField("float", options);
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Create a decimal field (stored as string for precision).
|
|
384
|
-
* @param options - Field configuration options including optional scale (0-12)
|
|
385
|
-
* @returns A decimal field
|
|
386
|
-
* @example db.decimal()
|
|
387
|
-
* @example db.decimal({ scale: 2 })
|
|
388
|
-
* @example db.decimal({ scale: 2, optional: true })
|
|
389
|
-
*/
|
|
390
|
-
function decimal(options) {
|
|
391
|
-
if (options?.scale !== void 0) {
|
|
392
|
-
if (!Number.isInteger(options.scale) || options.scale < 0 || options.scale > 12) throw new Error("scale must be an integer between 0 and 12");
|
|
393
|
-
}
|
|
394
|
-
const field = createField("decimal", options);
|
|
395
|
-
if (options?.scale !== void 0) field._metadata.scale = options.scale;
|
|
396
|
-
return field;
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Create a date field (date only, no time component).
|
|
400
|
-
* Format: "yyyy-MM-dd"
|
|
401
|
-
* @param options - Field configuration options
|
|
402
|
-
* @returns A date field
|
|
403
|
-
* @example db.date()
|
|
404
|
-
*/
|
|
405
|
-
function date(options) {
|
|
406
|
-
return createField("date", options);
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Create a datetime field (date and time).
|
|
410
|
-
* Format: ISO 8601, such as "yyyy-MM-ddTHH:mm:ssZ" or "yyyy-MM-ddTHH:mm:ss+09:00"
|
|
411
|
-
* @param options - Field configuration options
|
|
412
|
-
* @returns A datetime field
|
|
413
|
-
* @example db.datetime()
|
|
414
|
-
*/
|
|
415
|
-
function datetime(options) {
|
|
416
|
-
return createField("datetime", options);
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Create a time field (time only, no date component).
|
|
420
|
-
* Format: "HH:mm"
|
|
421
|
-
* @param options - Field configuration options
|
|
422
|
-
* @returns A time field
|
|
423
|
-
* @example db.time()
|
|
424
|
-
*/
|
|
425
|
-
function time(options) {
|
|
426
|
-
return createField("time", options);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Create an enum field with a fixed set of allowed string values.
|
|
430
|
-
* @param values - Array of allowed string values, or array of `{ value, description }` objects
|
|
431
|
-
* @param options - Field configuration options
|
|
432
|
-
* @returns An enum field
|
|
433
|
-
* @example db.enum(["active", "inactive", "suspended"])
|
|
434
|
-
* @example db.enum(["small", "medium", "large"], { optional: true })
|
|
435
|
-
*/
|
|
436
|
-
function _enum(values, options) {
|
|
437
|
-
return createField("enum", options, void 0, values);
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Create a nested object field with sub-fields.
|
|
441
|
-
* @param fields - Record of nested field definitions
|
|
442
|
-
* @param options - Field configuration options
|
|
443
|
-
* @returns A nested object field
|
|
444
|
-
* @example db.object({ street: db.string(), city: db.string(), zip: db.string() })
|
|
445
|
-
* @example db.object({ name: db.string() }, { optional: true })
|
|
446
|
-
*/
|
|
447
|
-
function object(fields, options) {
|
|
448
|
-
return createField("nested", options, fields);
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Creates a new TailorDBType instance.
|
|
452
|
-
* @param name - Type name
|
|
453
|
-
* @param fields - Field definitions
|
|
454
|
-
* @param options - Type options
|
|
455
|
-
* @param options.pluralForm - Optional plural form
|
|
456
|
-
* @param options.description - Optional description
|
|
457
|
-
* @returns A new TailorDBType
|
|
458
|
-
*/
|
|
459
|
-
function createTailorDBType(name, fields, options) {
|
|
460
|
-
let _description = options.description;
|
|
461
|
-
let _settings = {};
|
|
462
|
-
let _indexes = [];
|
|
463
|
-
const _permissions = {};
|
|
464
|
-
let _files = {};
|
|
465
|
-
const _plugins = [];
|
|
466
|
-
let _typeHook;
|
|
467
|
-
let _typeValidate;
|
|
468
|
-
const _definedMethods = /* @__PURE__ */ new Set();
|
|
469
|
-
if (options.description !== void 0) _definedMethods.add("description");
|
|
470
|
-
function runMethodOnce(method, action) {
|
|
471
|
-
if (_definedMethods.has(method)) throw new Error(`.${method}() has already been set`);
|
|
472
|
-
const result = action();
|
|
473
|
-
_definedMethods.add(method);
|
|
474
|
-
return result;
|
|
475
|
-
}
|
|
476
|
-
if (options.pluralForm) {
|
|
477
|
-
if (name === options.pluralForm) throw new Error(`The name and the plural form must be different. name=${name}`);
|
|
478
|
-
_settings.pluralForm = options.pluralForm;
|
|
479
|
-
}
|
|
480
|
-
return brandValue({
|
|
481
|
-
name,
|
|
482
|
-
fields: { ...fields },
|
|
483
|
-
_output: null,
|
|
484
|
-
_description,
|
|
485
|
-
get metadata() {
|
|
486
|
-
const indexes = {};
|
|
487
|
-
if (_indexes.length > 0) _indexes.forEach((index) => {
|
|
488
|
-
const fieldNames = index.fields.map((field) => String(field));
|
|
489
|
-
const key = index.name || `idx_${fieldNames.join("_")}`;
|
|
490
|
-
indexes[key] = {
|
|
491
|
-
fields: fieldNames,
|
|
492
|
-
unique: index.unique
|
|
493
|
-
};
|
|
494
|
-
});
|
|
495
|
-
return {
|
|
496
|
-
name: this.name,
|
|
497
|
-
description: _description,
|
|
498
|
-
settings: _settings,
|
|
499
|
-
permissions: _permissions,
|
|
500
|
-
files: _files,
|
|
501
|
-
...Object.keys(indexes).length > 0 && { indexes },
|
|
502
|
-
..._typeHook && { typeHook: _typeHook },
|
|
503
|
-
..._typeValidate && { typeValidate: _typeValidate }
|
|
504
|
-
};
|
|
505
|
-
},
|
|
506
|
-
hooks(hook) {
|
|
507
|
-
return runMethodOnce("hooks", () => {
|
|
508
|
-
_typeHook = hook;
|
|
509
|
-
return this;
|
|
510
|
-
});
|
|
511
|
-
},
|
|
512
|
-
validate(fn) {
|
|
513
|
-
return runMethodOnce("validate", () => {
|
|
514
|
-
_typeValidate = fn;
|
|
515
|
-
return this;
|
|
516
|
-
});
|
|
517
|
-
},
|
|
518
|
-
features(features) {
|
|
519
|
-
return runMethodOnce("features", () => {
|
|
520
|
-
_settings = {
|
|
521
|
-
..._settings,
|
|
522
|
-
...features
|
|
523
|
-
};
|
|
524
|
-
return this;
|
|
525
|
-
});
|
|
526
|
-
},
|
|
527
|
-
indexes(...indexes) {
|
|
528
|
-
return runMethodOnce("indexes", () => {
|
|
529
|
-
_indexes = indexes;
|
|
530
|
-
return this;
|
|
531
|
-
});
|
|
532
|
-
},
|
|
533
|
-
files(files) {
|
|
534
|
-
return runMethodOnce("files", () => {
|
|
535
|
-
_files = files;
|
|
536
|
-
return this;
|
|
537
|
-
});
|
|
538
|
-
},
|
|
539
|
-
permission(permission) {
|
|
540
|
-
return runMethodOnce("permission", () => {
|
|
541
|
-
const ret = this;
|
|
542
|
-
_permissions.record = permission;
|
|
543
|
-
return ret;
|
|
544
|
-
});
|
|
545
|
-
},
|
|
546
|
-
gqlPermission(permission) {
|
|
547
|
-
return runMethodOnce("gqlPermission", () => {
|
|
548
|
-
const ret = this;
|
|
549
|
-
_permissions.gql = permission;
|
|
550
|
-
return ret;
|
|
551
|
-
});
|
|
552
|
-
},
|
|
553
|
-
description(description) {
|
|
554
|
-
return runMethodOnce("description", () => {
|
|
555
|
-
_description = description;
|
|
556
|
-
this._description = description;
|
|
557
|
-
return this;
|
|
558
|
-
});
|
|
559
|
-
},
|
|
560
|
-
pickFields(keys, options) {
|
|
561
|
-
const result = {};
|
|
562
|
-
for (const key of keys) {
|
|
563
|
-
const field = this.fields[key];
|
|
564
|
-
if (options) result[key] = field.clone(options);
|
|
565
|
-
else result[key] = field;
|
|
566
|
-
}
|
|
567
|
-
return result;
|
|
568
|
-
},
|
|
569
|
-
omitFields(keys) {
|
|
570
|
-
const keysSet = new Set(keys);
|
|
571
|
-
const result = {};
|
|
572
|
-
for (const key in this.fields) if (Object.hasOwn(this.fields, key) && !keysSet.has(key)) result[key] = this.fields[key];
|
|
573
|
-
return result;
|
|
574
|
-
},
|
|
575
|
-
get plugins() {
|
|
576
|
-
return _plugins;
|
|
577
|
-
},
|
|
578
|
-
plugin(config) {
|
|
579
|
-
for (const [pluginId, pluginConfig] of Object.entries(config)) _plugins.push({
|
|
580
|
-
pluginId,
|
|
581
|
-
config: pluginConfig
|
|
582
|
-
});
|
|
583
|
-
return this;
|
|
584
|
-
}
|
|
585
|
-
}, "tailordb-type");
|
|
586
|
-
}
|
|
587
|
-
const idField = uuid();
|
|
588
|
-
function dbTable(name, fieldsOrDescription, fields) {
|
|
589
|
-
const typeName = Array.isArray(name) ? name[0] : name;
|
|
590
|
-
const pluralForm = Array.isArray(name) ? name[1] : void 0;
|
|
591
|
-
let description;
|
|
592
|
-
let fieldDef;
|
|
593
|
-
if (typeof fieldsOrDescription === "string") {
|
|
594
|
-
description = fieldsOrDescription;
|
|
595
|
-
fieldDef = fields;
|
|
596
|
-
} else fieldDef = fieldsOrDescription;
|
|
597
|
-
return createTailorDBType(typeName, {
|
|
598
|
-
id: idField,
|
|
599
|
-
...fieldDef
|
|
600
|
-
}, {
|
|
601
|
-
pluralForm,
|
|
602
|
-
description
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
/** TailorDB schema builder utilities for defining tables and fields. */
|
|
606
|
-
const db = {
|
|
607
|
-
table: dbTable,
|
|
608
|
-
uuid,
|
|
609
|
-
string,
|
|
610
|
-
bool,
|
|
611
|
-
int,
|
|
612
|
-
float,
|
|
613
|
-
decimal,
|
|
614
|
-
date,
|
|
615
|
-
datetime,
|
|
616
|
-
time,
|
|
617
|
-
enum: _enum,
|
|
618
|
-
object,
|
|
619
|
-
fields: {
|
|
620
|
-
/**
|
|
621
|
-
* Creates standard timestamp fields (createdAt, updatedAt) with automatic defaults.
|
|
622
|
-
* Both fields default to the current time on create. updatedAt is also refreshed on update.
|
|
623
|
-
* User-specified values are respected when provided (e.g. seeding historical records).
|
|
624
|
-
* @returns An object with createdAt and updatedAt fields
|
|
625
|
-
* @example
|
|
626
|
-
* const model = db.table("Model", {
|
|
627
|
-
* name: db.string(),
|
|
628
|
-
* ...db.fields.timestamps(),
|
|
629
|
-
* });
|
|
630
|
-
*/
|
|
631
|
-
timestamps: () => ({
|
|
632
|
-
createdAt: datetime().default("now").description("Record creation timestamp"),
|
|
633
|
-
updatedAt: datetime().default("now").hooks({ update: ({ input, now }) => input ?? now }).description("Record update timestamp")
|
|
634
|
-
}) }
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
//#endregion
|
|
638
|
-
export { parseInternal as i, mapAllowedValues as n, parseInputFields as r, db as t };
|
|
639
|
-
//# sourceMappingURL=schema--xYWRGfe.mjs.map
|