@hot-updater/plugin-core 1.0.0-rc.17 → 1.0.0-rc.21

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.
Files changed (190) hide show
  1. package/README.md +33 -0
  2. package/dist/baseCandidateKey.cjs +50 -0
  3. package/dist/baseCandidateKey.d.cts +27 -0
  4. package/dist/baseCandidateKey.d.mts +27 -0
  5. package/dist/baseCandidateKey.mjs +49 -0
  6. package/dist/createStorageAdapter.cjs +8 -0
  7. package/dist/createStorageAdapter.d.cts +9 -0
  8. package/dist/createStorageAdapter.d.mts +9 -0
  9. package/dist/createStorageAdapter.mjs +7 -0
  10. package/dist/database/adapter.cjs +20 -5
  11. package/dist/database/adapter.d.cts +25 -8
  12. package/dist/database/adapter.d.mts +25 -8
  13. package/dist/database/adapter.mjs +21 -4
  14. package/dist/database/distinct.cjs +12 -6
  15. package/dist/database/distinct.d.cts +13 -11
  16. package/dist/database/distinct.d.mts +13 -11
  17. package/dist/database/distinct.mjs +13 -6
  18. package/dist/database/memoryAdapter.cjs +2 -10
  19. package/dist/database/memoryAdapter.d.cts +2 -4
  20. package/dist/database/memoryAdapter.d.mts +2 -4
  21. package/dist/database/memoryAdapter.mjs +2 -10
  22. package/dist/database/values.cjs +5 -1
  23. package/dist/database/values.d.cts +8 -21
  24. package/dist/database/values.d.mts +8 -21
  25. package/dist/database/values.mjs +5 -1
  26. package/dist/database/verifyAdapter.cjs +1 -0
  27. package/dist/database/verifyAdapter.d.cts +8 -0
  28. package/dist/database/verifyAdapter.d.mts +8 -0
  29. package/dist/database/verifyAdapter.mjs +1 -0
  30. package/dist/databaseErrors.cjs +4 -4
  31. package/dist/databaseErrors.d.cts +6 -6
  32. package/dist/databaseErrors.d.mts +6 -6
  33. package/dist/databaseErrors.mjs +4 -4
  34. package/dist/databaseJsonValue.cjs +6 -0
  35. package/dist/databaseJsonValue.d.cts +6 -0
  36. package/dist/databaseJsonValue.d.mts +6 -0
  37. package/dist/databaseJsonValue.mjs +6 -0
  38. package/dist/databaseMetadata.cjs +3 -3
  39. package/dist/databaseMetadata.mjs +3 -3
  40. package/dist/databaseRows.cjs +6 -6
  41. package/dist/databaseRows.d.cts +1 -1
  42. package/dist/databaseRows.d.mts +1 -1
  43. package/dist/databaseRows.mjs +1 -1
  44. package/dist/engine/core/schema.cjs +279 -0
  45. package/dist/engine/core/schema.d.cts +312 -0
  46. package/dist/engine/core/schema.d.mts +312 -0
  47. package/dist/engine/core/schema.mjs +277 -0
  48. package/dist/engine/createEngine.cjs +72 -0
  49. package/dist/engine/createEngine.d.cts +45 -0
  50. package/dist/engine/createEngine.d.mts +45 -0
  51. package/dist/engine/createEngine.mjs +72 -0
  52. package/dist/engine/database/aggregateBatching.cjs +627 -0
  53. package/dist/engine/database/aggregateBatching.mjs +626 -0
  54. package/dist/engine/database/cursor.cjs +42 -0
  55. package/dist/engine/database/cursor.mjs +38 -0
  56. package/dist/engine/database/database.cjs +68 -0
  57. package/dist/engine/database/database.mjs +68 -0
  58. package/dist/engine/database/engine.cjs +37 -0
  59. package/dist/engine/database/engine.mjs +37 -0
  60. package/dist/engine/database/engineAggregates.cjs +120 -0
  61. package/dist/engine/database/engineAggregates.mjs +117 -0
  62. package/dist/engine/database/engineReads.cjs +182 -0
  63. package/dist/engine/database/engineReads.d.cts +10 -0
  64. package/dist/engine/database/engineReads.d.mts +10 -0
  65. package/dist/engine/database/engineReads.mjs +181 -0
  66. package/dist/engine/database/engineTransaction.cjs +399 -0
  67. package/dist/engine/database/engineTransaction.d.cts +18 -0
  68. package/dist/engine/database/engineTransaction.d.mts +18 -0
  69. package/dist/engine/database/engineTransaction.mjs +398 -0
  70. package/dist/engine/database/fence.cjs +156 -0
  71. package/dist/engine/database/fence.d.cts +41 -0
  72. package/dist/engine/database/fence.d.mts +41 -0
  73. package/dist/engine/database/fence.mjs +149 -0
  74. package/dist/engine/database/kv/kvAdapter.cjs +293 -0
  75. package/dist/engine/database/kv/kvAdapter.d.cts +116 -0
  76. package/dist/engine/database/kv/kvAdapter.d.mts +116 -0
  77. package/dist/engine/database/kv/kvAdapter.mjs +292 -0
  78. package/dist/engine/database/readMeter.cjs +80 -0
  79. package/dist/engine/database/readMeter.d.cts +34 -0
  80. package/dist/engine/database/readMeter.d.mts +34 -0
  81. package/dist/engine/database/readMeter.mjs +79 -0
  82. package/dist/engine/database/resolveSchema.cjs +197 -0
  83. package/dist/engine/database/resolveSchema.d.cts +35 -0
  84. package/dist/engine/database/resolveSchema.d.mts +35 -0
  85. package/dist/engine/database/resolveSchema.mjs +195 -0
  86. package/dist/engine/database/retention.cjs +100 -0
  87. package/dist/engine/database/retention.mjs +98 -0
  88. package/dist/engine/database/sql/sqlAdapter.cjs +290 -0
  89. package/dist/engine/database/sql/sqlAdapter.d.cts +45 -0
  90. package/dist/engine/database/sql/sqlAdapter.d.mts +45 -0
  91. package/dist/engine/database/sql/sqlAdapter.mjs +288 -0
  92. package/dist/engine/database/sql/sqlSchema.cjs +175 -0
  93. package/dist/engine/database/sql/sqlSchema.d.cts +45 -0
  94. package/dist/engine/database/sql/sqlSchema.d.mts +45 -0
  95. package/dist/engine/database/sql/sqlSchema.mjs +169 -0
  96. package/dist/engine/db/coreDatabase.cjs +94 -0
  97. package/dist/engine/db/coreDatabase.d.cts +78 -0
  98. package/dist/engine/db/coreDatabase.d.mts +78 -0
  99. package/dist/engine/db/coreDatabase.mjs +86 -0
  100. package/dist/engine/db/engineMigrator.cjs +53 -0
  101. package/dist/engine/db/engineMigrator.mjs +53 -0
  102. package/dist/engine/db/engineSql.cjs +26 -0
  103. package/dist/engine/db/engineSql.d.cts +16 -0
  104. package/dist/engine/db/engineSql.d.mts +16 -0
  105. package/dist/engine/db/engineSql.mjs +25 -0
  106. package/dist/engine/db/engineSqlMigrator.cjs +67 -0
  107. package/dist/engine/db/engineSqlMigrator.d.cts +21 -0
  108. package/dist/engine/db/engineSqlMigrator.d.mts +21 -0
  109. package/dist/engine/db/engineSqlMigrator.mjs +67 -0
  110. package/dist/engine/db/fixedMigratorShared.cjs +12 -0
  111. package/dist/engine/db/fixedMigratorShared.mjs +11 -0
  112. package/dist/engine/db/schemaSettings.cjs +63 -0
  113. package/dist/engine/db/schemaSettings.d.cts +7 -0
  114. package/dist/engine/db/schemaSettings.d.mts +7 -0
  115. package/dist/engine/db/schemaSettings.mjs +62 -0
  116. package/dist/engine/db/settingsMigrator.cjs +94 -0
  117. package/dist/engine/db/settingsMigrator.d.cts +25 -0
  118. package/dist/engine/db/settingsMigrator.d.mts +25 -0
  119. package/dist/engine/db/settingsMigrator.mjs +91 -0
  120. package/dist/engine/db/types.d.cts +78 -0
  121. package/dist/engine/db/types.d.mts +78 -0
  122. package/dist/index.cjs +86 -7
  123. package/dist/index.d.cts +36 -6
  124. package/dist/index.d.mts +36 -6
  125. package/dist/index.mjs +26 -4
  126. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.cjs +0 -5
  127. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs +1 -5
  128. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.cjs +8 -0
  129. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/range-DvX-Y6iv.mjs +9 -2
  130. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.cjs +4 -0
  131. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/set-CC5YeoYX.mjs +4 -1
  132. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.cjs +0 -5
  133. package/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/version-CQ98ZBpL.mjs +2 -6
  134. package/dist/releaseCatalogCompiler.cjs +26 -25
  135. package/dist/releaseCatalogCompiler.d.cts +1 -2
  136. package/dist/releaseCatalogCompiler.d.mts +2 -3
  137. package/dist/releaseCatalogCompiler.mjs +3 -7
  138. package/dist/remoteBundleSigning.d.cts +2 -2
  139. package/dist/remoteBundleSigning.d.mts +2 -2
  140. package/dist/serverPlugin/busy.cjs +36 -0
  141. package/dist/serverPlugin/busy.d.cts +12 -0
  142. package/dist/serverPlugin/busy.d.mts +12 -0
  143. package/dist/serverPlugin/busy.mjs +36 -0
  144. package/dist/serverPlugin/configError.cjs +7 -0
  145. package/dist/serverPlugin/configError.d.cts +7 -0
  146. package/dist/serverPlugin/configError.d.mts +7 -0
  147. package/dist/serverPlugin/configError.mjs +7 -0
  148. package/dist/serverPlugin/coreReads.d.cts +48 -0
  149. package/dist/serverPlugin/coreReads.d.mts +48 -0
  150. package/dist/serverPlugin/databaseHandle.d.cts +105 -0
  151. package/dist/serverPlugin/databaseHandle.d.mts +105 -0
  152. package/dist/serverPlugin/definePlugin.cjs +5 -0
  153. package/dist/serverPlugin/definePlugin.d.cts +130 -0
  154. package/dist/serverPlugin/definePlugin.d.mts +130 -0
  155. package/dist/serverPlugin/definePlugin.mjs +5 -0
  156. package/dist/serverPlugin/definitions.d.cts +76 -0
  157. package/dist/serverPlugin/definitions.d.mts +76 -0
  158. package/dist/serverPlugin/errors.cjs +37 -0
  159. package/dist/serverPlugin/errors.d.cts +29 -0
  160. package/dist/serverPlugin/errors.d.mts +29 -0
  161. package/dist/serverPlugin/errors.mjs +32 -0
  162. package/dist/serverPlugin/schema.cjs +24 -0
  163. package/dist/serverPlugin/schema.d.cts +90 -0
  164. package/dist/serverPlugin/schema.d.mts +90 -0
  165. package/dist/serverPlugin/schema.mjs +23 -0
  166. package/dist/types/databaseConfig.cjs +1 -1
  167. package/dist/types/databaseConfig.d.cts +8 -1
  168. package/dist/types/databaseConfig.d.mts +8 -1
  169. package/dist/types/databaseConfig.mjs +1 -1
  170. package/dist/types/databaseRows.d.cts +1 -1
  171. package/dist/types/databaseRows.d.mts +1 -1
  172. package/dist/types/index.d.cts +26 -14
  173. package/dist/types/index.d.mts +26 -14
  174. package/dist/types/public.d.cts +1 -1
  175. package/dist/types/public.d.mts +1 -1
  176. package/dist/uuidv7.cjs +3 -3
  177. package/dist/uuidv7.d.cts +1 -1
  178. package/dist/uuidv7.d.mts +1 -1
  179. package/dist/uuidv7.mjs +1 -1
  180. package/package.json +10 -7
  181. package/dist/createStoragePlugin.cjs +0 -8
  182. package/dist/createStoragePlugin.d.cts +0 -9
  183. package/dist/createStoragePlugin.d.mts +0 -9
  184. package/dist/createStoragePlugin.mjs +0 -7
  185. package/dist/internal.cjs +0 -38
  186. package/dist/internal.d.cts +0 -12
  187. package/dist/internal.d.mts +0 -12
  188. package/dist/internal.mjs +0 -8
  189. package/dist/types/internal.d.cts +0 -4
  190. package/dist/types/internal.d.mts +0 -4
@@ -0,0 +1,130 @@
1
+ import { CoreReads } from "./coreReads.cjs";
2
+ import { ModuleSchema } from "./schema.cjs";
3
+ import { HotUpdaterDatabase } from "./databaseHandle.cjs";
4
+ //#region src/serverPlugin/definePlugin.d.ts
5
+ type PluginEndpointMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
6
+ interface PluginEndpoint {
7
+ readonly method: PluginEndpointMethod;
8
+ /** Relative to the handler's mount; `:name` segments become `params`. */
9
+ readonly path: string;
10
+ /**
11
+ * `"client"` mounts on `handlers.client` behind the client-route policy;
12
+ * `"admin"` mounts on `handlers.admin`, which the host protects.
13
+ */
14
+ readonly access: "client" | "admin";
15
+ readonly handler: (request: Request, params: Readonly<Record<string, string>>) => Promise<Response>;
16
+ }
17
+ /** The client-route policy a plugin provides, such as a key or token check. */
18
+ interface ClientAuth {
19
+ /** Request headers the decision reads; core adds them to `Vary` on cacheable client responses. */
20
+ readonly varyHeaders: readonly string[];
21
+ /** Whether the request may use client routes; a throw answers 503. */
22
+ authenticate(headers: Headers): Promise<boolean>;
23
+ }
24
+ interface PluginInstance<Api = unknown> {
25
+ readonly api: Api;
26
+ readonly endpoints?: readonly PluginEndpoint[];
27
+ readonly clientAuth?: ClientAuth;
28
+ }
29
+ /** Core's reads: bundles, Releases, Catalogs, and channels, each through a declared index. Plugins never write core. */
30
+ type CoreReader = CoreReads;
31
+ interface PluginContext<S extends ModuleSchema> {
32
+ /** The plugin's own tables and aggregates. */
33
+ readonly db: HotUpdaterDatabase<S>;
34
+ readonly core: CoreReader;
35
+ now(): number;
36
+ }
37
+ interface PluginProvides {
38
+ readonly clientAuth?: true;
39
+ }
40
+ /** An instance whose `clientAuth` matches what the plugin declares it provides. */
41
+ type InstanceFor<TProvides, TInstance> = TProvides extends {
42
+ readonly clientAuth: true;
43
+ } ? TInstance & {
44
+ readonly clientAuth: ClientAuth;
45
+ } : TInstance & {
46
+ readonly clientAuth?: "Declare provides: { clientAuth: true } to return clientAuth";
47
+ };
48
+ /**
49
+ * The credential an app sends to client routes that the plugin's clientAuth
50
+ * guards. Init provisions it and prints the header to send, the agent
51
+ * scaffold stores it, and doctor checks it.
52
+ */
53
+ interface PluginClientCredential<Api = unknown> {
54
+ /** Its name in output, such as "API key". */
55
+ readonly label: string;
56
+ /** The request header that carries it, one of clientAuth's varyHeaders. */
57
+ readonly header: string;
58
+ /** The environment variable init stores it in. */
59
+ readonly env: string;
60
+ /** A new credential, made without a database, so tooling can save it before registering it. */
61
+ generate(): string;
62
+ /** Registers `existing` idempotently, or creates one; returns the credential. */
63
+ provision(api: Api, input: {
64
+ readonly existing?: string;
65
+ readonly name: string;
66
+ }): Promise<string>;
67
+ }
68
+ /**
69
+ * A client plugin an app adds to `HotUpdater.init`'s `plugins` to work with
70
+ * the server plugin. Init prints it in the app code, and the agent scaffold
71
+ * asks for it.
72
+ */
73
+ interface PluginClientPlugin {
74
+ /** The module that exports it, such as `@hot-updater/react-native`, which exports `insights`. */
75
+ readonly module: string;
76
+ /** The export, which the app calls with no arguments, such as `insights`. */
77
+ readonly name: string;
78
+ }
79
+ /**
80
+ * What the CLI reads from a plugin: the credential init provisions, and the
81
+ * client plugin init prints and doctor checks.
82
+ */
83
+ interface PluginCli<Api = unknown> {
84
+ /** Needs provides: { clientAuth: true }. */
85
+ readonly clientCredential?: PluginClientCredential<Api>;
86
+ readonly clientPlugin?: PluginClientPlugin;
87
+ }
88
+ /** CLI additions whose `clientCredential` matches what the plugin declares it provides. */
89
+ type CliFor<TProvides, TApi> = TProvides extends {
90
+ readonly clientAuth: true;
91
+ } ? PluginCli<TApi> : Omit<PluginCli<TApi>, "clientCredential"> & {
92
+ readonly clientCredential?: "Declare provides: { clientAuth: true } to add clientCredential";
93
+ };
94
+ interface HotUpdaterPlugin<TId extends string = string, TSchema extends ModuleSchema = ModuleSchema, TInstance extends PluginInstance = PluginInstance, TProvides extends PluginProvides = PluginProvides> {
95
+ readonly id: TId;
96
+ /** Static, so the type system and startup can count client-route policies. */
97
+ readonly provides?: TProvides;
98
+ /** Stored under the settings key `schema.<id>`. */
99
+ readonly schemaVersion: string;
100
+ readonly schema: TSchema;
101
+ /**
102
+ * `false` keeps the declared table names instead of prefixing them with
103
+ * the plugin's id. The plugin then owns collisions with core's tables and
104
+ * other plugins' tables, which startup checks for the plugins a server
105
+ * runs, and only such a plugin may take a camelCase id.
106
+ */
107
+ readonly namespace?: false;
108
+ /** Called once at startup, synchronously. */
109
+ init(context: PluginContext<TSchema>): TInstance;
110
+ /** Read by the CLI only; the server never runs it. */
111
+ readonly cli?: PluginCli<TInstance["api"]>;
112
+ /** Only core modules carry a kind. */
113
+ readonly kind?: "Core is built in; it is not a plugin";
114
+ }
115
+ /** Declares a plugin; Hot Updater's own plugins and third-party ones use the same contract. */
116
+ declare const definePlugin: <const TId extends string, const TSchema extends ModuleSchema, TInstance extends PluginInstance, const TProvides extends PluginProvides = {}>(plugin: {
117
+ readonly id: TId;
118
+ readonly provides?: TProvides;
119
+ readonly schemaVersion: string;
120
+ readonly schema: TSchema;
121
+ readonly namespace?: false;
122
+ init(context: PluginContext<TSchema>): InstanceFor<TProvides, TInstance>;
123
+ readonly cli?: CliFor<TProvides, NoInfer<TInstance["api"]>>;
124
+ }) => HotUpdaterPlugin<TId, TSchema, TInstance, TProvides>;
125
+ /** Any plugin, whatever its schema and API. */
126
+ type AnyHotUpdaterPlugin = HotUpdaterPlugin<string, any, any, any>;
127
+ /** Each plugin's API by id. */
128
+ type PluginApis<TPlugins extends readonly AnyHotUpdaterPlugin[]> = { readonly [TPlugin in TPlugins[number] as TPlugin["id"]]: ReturnType<TPlugin["init"]>["api"]; };
129
+ //#endregion
130
+ export { AnyHotUpdaterPlugin, CliFor, ClientAuth, CoreReader, HotUpdaterPlugin, InstanceFor, PluginApis, PluginCli, PluginClientCredential, PluginClientPlugin, PluginContext, PluginEndpoint, PluginEndpointMethod, PluginInstance, PluginProvides, definePlugin };
@@ -0,0 +1,130 @@
1
+ import { CoreReads } from "./coreReads.mjs";
2
+ import { ModuleSchema } from "./schema.mjs";
3
+ import { HotUpdaterDatabase } from "./databaseHandle.mjs";
4
+ //#region src/serverPlugin/definePlugin.d.ts
5
+ type PluginEndpointMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
6
+ interface PluginEndpoint {
7
+ readonly method: PluginEndpointMethod;
8
+ /** Relative to the handler's mount; `:name` segments become `params`. */
9
+ readonly path: string;
10
+ /**
11
+ * `"client"` mounts on `handlers.client` behind the client-route policy;
12
+ * `"admin"` mounts on `handlers.admin`, which the host protects.
13
+ */
14
+ readonly access: "client" | "admin";
15
+ readonly handler: (request: Request, params: Readonly<Record<string, string>>) => Promise<Response>;
16
+ }
17
+ /** The client-route policy a plugin provides, such as a key or token check. */
18
+ interface ClientAuth {
19
+ /** Request headers the decision reads; core adds them to `Vary` on cacheable client responses. */
20
+ readonly varyHeaders: readonly string[];
21
+ /** Whether the request may use client routes; a throw answers 503. */
22
+ authenticate(headers: Headers): Promise<boolean>;
23
+ }
24
+ interface PluginInstance<Api = unknown> {
25
+ readonly api: Api;
26
+ readonly endpoints?: readonly PluginEndpoint[];
27
+ readonly clientAuth?: ClientAuth;
28
+ }
29
+ /** Core's reads: bundles, Releases, Catalogs, and channels, each through a declared index. Plugins never write core. */
30
+ type CoreReader = CoreReads;
31
+ interface PluginContext<S extends ModuleSchema> {
32
+ /** The plugin's own tables and aggregates. */
33
+ readonly db: HotUpdaterDatabase<S>;
34
+ readonly core: CoreReader;
35
+ now(): number;
36
+ }
37
+ interface PluginProvides {
38
+ readonly clientAuth?: true;
39
+ }
40
+ /** An instance whose `clientAuth` matches what the plugin declares it provides. */
41
+ type InstanceFor<TProvides, TInstance> = TProvides extends {
42
+ readonly clientAuth: true;
43
+ } ? TInstance & {
44
+ readonly clientAuth: ClientAuth;
45
+ } : TInstance & {
46
+ readonly clientAuth?: "Declare provides: { clientAuth: true } to return clientAuth";
47
+ };
48
+ /**
49
+ * The credential an app sends to client routes that the plugin's clientAuth
50
+ * guards. Init provisions it and prints the header to send, the agent
51
+ * scaffold stores it, and doctor checks it.
52
+ */
53
+ interface PluginClientCredential<Api = unknown> {
54
+ /** Its name in output, such as "API key". */
55
+ readonly label: string;
56
+ /** The request header that carries it, one of clientAuth's varyHeaders. */
57
+ readonly header: string;
58
+ /** The environment variable init stores it in. */
59
+ readonly env: string;
60
+ /** A new credential, made without a database, so tooling can save it before registering it. */
61
+ generate(): string;
62
+ /** Registers `existing` idempotently, or creates one; returns the credential. */
63
+ provision(api: Api, input: {
64
+ readonly existing?: string;
65
+ readonly name: string;
66
+ }): Promise<string>;
67
+ }
68
+ /**
69
+ * A client plugin an app adds to `HotUpdater.init`'s `plugins` to work with
70
+ * the server plugin. Init prints it in the app code, and the agent scaffold
71
+ * asks for it.
72
+ */
73
+ interface PluginClientPlugin {
74
+ /** The module that exports it, such as `@hot-updater/react-native`, which exports `insights`. */
75
+ readonly module: string;
76
+ /** The export, which the app calls with no arguments, such as `insights`. */
77
+ readonly name: string;
78
+ }
79
+ /**
80
+ * What the CLI reads from a plugin: the credential init provisions, and the
81
+ * client plugin init prints and doctor checks.
82
+ */
83
+ interface PluginCli<Api = unknown> {
84
+ /** Needs provides: { clientAuth: true }. */
85
+ readonly clientCredential?: PluginClientCredential<Api>;
86
+ readonly clientPlugin?: PluginClientPlugin;
87
+ }
88
+ /** CLI additions whose `clientCredential` matches what the plugin declares it provides. */
89
+ type CliFor<TProvides, TApi> = TProvides extends {
90
+ readonly clientAuth: true;
91
+ } ? PluginCli<TApi> : Omit<PluginCli<TApi>, "clientCredential"> & {
92
+ readonly clientCredential?: "Declare provides: { clientAuth: true } to add clientCredential";
93
+ };
94
+ interface HotUpdaterPlugin<TId extends string = string, TSchema extends ModuleSchema = ModuleSchema, TInstance extends PluginInstance = PluginInstance, TProvides extends PluginProvides = PluginProvides> {
95
+ readonly id: TId;
96
+ /** Static, so the type system and startup can count client-route policies. */
97
+ readonly provides?: TProvides;
98
+ /** Stored under the settings key `schema.<id>`. */
99
+ readonly schemaVersion: string;
100
+ readonly schema: TSchema;
101
+ /**
102
+ * `false` keeps the declared table names instead of prefixing them with
103
+ * the plugin's id. The plugin then owns collisions with core's tables and
104
+ * other plugins' tables, which startup checks for the plugins a server
105
+ * runs, and only such a plugin may take a camelCase id.
106
+ */
107
+ readonly namespace?: false;
108
+ /** Called once at startup, synchronously. */
109
+ init(context: PluginContext<TSchema>): TInstance;
110
+ /** Read by the CLI only; the server never runs it. */
111
+ readonly cli?: PluginCli<TInstance["api"]>;
112
+ /** Only core modules carry a kind. */
113
+ readonly kind?: "Core is built in; it is not a plugin";
114
+ }
115
+ /** Declares a plugin; Hot Updater's own plugins and third-party ones use the same contract. */
116
+ declare const definePlugin: <const TId extends string, const TSchema extends ModuleSchema, TInstance extends PluginInstance, const TProvides extends PluginProvides = {}>(plugin: {
117
+ readonly id: TId;
118
+ readonly provides?: TProvides;
119
+ readonly schemaVersion: string;
120
+ readonly schema: TSchema;
121
+ readonly namespace?: false;
122
+ init(context: PluginContext<TSchema>): InstanceFor<TProvides, TInstance>;
123
+ readonly cli?: CliFor<TProvides, NoInfer<TInstance["api"]>>;
124
+ }) => HotUpdaterPlugin<TId, TSchema, TInstance, TProvides>;
125
+ /** Any plugin, whatever its schema and API. */
126
+ type AnyHotUpdaterPlugin = HotUpdaterPlugin<string, any, any, any>;
127
+ /** Each plugin's API by id. */
128
+ type PluginApis<TPlugins extends readonly AnyHotUpdaterPlugin[]> = { readonly [TPlugin in TPlugins[number] as TPlugin["id"]]: ReturnType<TPlugin["init"]>["api"]; };
129
+ //#endregion
130
+ export { AnyHotUpdaterPlugin, CliFor, ClientAuth, CoreReader, HotUpdaterPlugin, InstanceFor, PluginApis, PluginCli, PluginClientCredential, PluginClientPlugin, PluginContext, PluginEndpoint, PluginEndpointMethod, PluginInstance, PluginProvides, definePlugin };
@@ -0,0 +1,5 @@
1
+ //#region src/serverPlugin/definePlugin.ts
2
+ /** Declares a plugin; Hot Updater's own plugins and third-party ones use the same contract. */
3
+ const definePlugin = (plugin) => plugin;
4
+ //#endregion
5
+ export { definePlugin };
@@ -0,0 +1,76 @@
1
+ //#region src/serverPlugin/definitions.d.ts
2
+ /**
3
+ * The model declarations the engine reads. `defineTable` and
4
+ * `defineAggregate` (./schema) build them with typed rows.
5
+ */
6
+ type FieldType = "string" | "integer" | "number" | "boolean" | "json";
7
+ type ReferenceAction = "restrict" | "cascade" | "none";
8
+ interface FieldReference {
9
+ readonly model: string;
10
+ readonly onDelete: ReferenceAction;
11
+ }
12
+ interface FieldDefinition<TType extends FieldType = FieldType> {
13
+ readonly type: TType;
14
+ /** Defaults to true; an optional field stores null. */
15
+ readonly required?: boolean;
16
+ /** Adds a unique index named after the field. */
17
+ readonly unique?: true;
18
+ /** Strings: the maximum length; unbounded text when absent. */
19
+ readonly maxLength?: number;
20
+ /** Strings: ASCII only, so a long key fits MySQL's 3,072-byte index limit. */
21
+ readonly ascii?: true;
22
+ readonly references?: FieldReference;
23
+ }
24
+ interface IndexDefinition<TField extends string = string> {
25
+ readonly eq: readonly TField[];
26
+ readonly sort: readonly TField[];
27
+ /** The eq values identify at most one row. */
28
+ readonly unique?: true;
29
+ /** `eq` starts with the key of a `model` row, which every child write bumps. */
30
+ readonly root?: {
31
+ readonly model: string;
32
+ };
33
+ }
34
+ /** A field computed on every write and stored as a real column. */
35
+ interface DerivedShape {
36
+ readonly type: FieldType;
37
+ /** Up to 16 values; the row is indexed once per value. */
38
+ readonly multi?: true;
39
+ /** Null, or an empty list, leaves the row out of indexes on this field. */
40
+ compute(row: never): unknown;
41
+ }
42
+ interface TableShape {
43
+ readonly kind: "table";
44
+ readonly fields: Readonly<Record<string, FieldDefinition>>;
45
+ readonly key: readonly string[];
46
+ readonly derived: Readonly<Record<string, DerivedShape>>;
47
+ readonly indexes: Readonly<Record<string, IndexDefinition>>;
48
+ /** Rows expire `days` after the epoch milliseconds in `field`. */
49
+ readonly retention?: {
50
+ readonly field: string;
51
+ readonly days: number;
52
+ };
53
+ }
54
+ interface AggregateShape {
55
+ readonly kind: "aggregate";
56
+ /** Identity fields; `key` lists them in declaration order. */
57
+ readonly fields: Readonly<Record<string, FieldDefinition>>;
58
+ readonly key: readonly string[];
59
+ /** Blind increments. */
60
+ readonly counters: readonly string[];
61
+ /** Read, merged, and written back per shard; a row at zero is deleted. */
62
+ readonly gauges: readonly string[];
63
+ /** HLL sketches, kept in aggregates of their own. */
64
+ readonly distinct: readonly string[];
65
+ /** Fixed once data exists. */
66
+ readonly shards: number;
67
+ readonly indexes: Readonly<Record<string, IndexDefinition>>;
68
+ /** On an identity field; a change to a row past it is dropped. */
69
+ readonly retention?: {
70
+ readonly field: string;
71
+ readonly days: number;
72
+ };
73
+ }
74
+ type ModelShape = TableShape | AggregateShape;
75
+ //#endregion
76
+ export { AggregateShape, DerivedShape, FieldDefinition, FieldReference, FieldType, IndexDefinition, ModelShape, ReferenceAction, TableShape };
@@ -0,0 +1,76 @@
1
+ //#region src/serverPlugin/definitions.d.ts
2
+ /**
3
+ * The model declarations the engine reads. `defineTable` and
4
+ * `defineAggregate` (./schema) build them with typed rows.
5
+ */
6
+ type FieldType = "string" | "integer" | "number" | "boolean" | "json";
7
+ type ReferenceAction = "restrict" | "cascade" | "none";
8
+ interface FieldReference {
9
+ readonly model: string;
10
+ readonly onDelete: ReferenceAction;
11
+ }
12
+ interface FieldDefinition<TType extends FieldType = FieldType> {
13
+ readonly type: TType;
14
+ /** Defaults to true; an optional field stores null. */
15
+ readonly required?: boolean;
16
+ /** Adds a unique index named after the field. */
17
+ readonly unique?: true;
18
+ /** Strings: the maximum length; unbounded text when absent. */
19
+ readonly maxLength?: number;
20
+ /** Strings: ASCII only, so a long key fits MySQL's 3,072-byte index limit. */
21
+ readonly ascii?: true;
22
+ readonly references?: FieldReference;
23
+ }
24
+ interface IndexDefinition<TField extends string = string> {
25
+ readonly eq: readonly TField[];
26
+ readonly sort: readonly TField[];
27
+ /** The eq values identify at most one row. */
28
+ readonly unique?: true;
29
+ /** `eq` starts with the key of a `model` row, which every child write bumps. */
30
+ readonly root?: {
31
+ readonly model: string;
32
+ };
33
+ }
34
+ /** A field computed on every write and stored as a real column. */
35
+ interface DerivedShape {
36
+ readonly type: FieldType;
37
+ /** Up to 16 values; the row is indexed once per value. */
38
+ readonly multi?: true;
39
+ /** Null, or an empty list, leaves the row out of indexes on this field. */
40
+ compute(row: never): unknown;
41
+ }
42
+ interface TableShape {
43
+ readonly kind: "table";
44
+ readonly fields: Readonly<Record<string, FieldDefinition>>;
45
+ readonly key: readonly string[];
46
+ readonly derived: Readonly<Record<string, DerivedShape>>;
47
+ readonly indexes: Readonly<Record<string, IndexDefinition>>;
48
+ /** Rows expire `days` after the epoch milliseconds in `field`. */
49
+ readonly retention?: {
50
+ readonly field: string;
51
+ readonly days: number;
52
+ };
53
+ }
54
+ interface AggregateShape {
55
+ readonly kind: "aggregate";
56
+ /** Identity fields; `key` lists them in declaration order. */
57
+ readonly fields: Readonly<Record<string, FieldDefinition>>;
58
+ readonly key: readonly string[];
59
+ /** Blind increments. */
60
+ readonly counters: readonly string[];
61
+ /** Read, merged, and written back per shard; a row at zero is deleted. */
62
+ readonly gauges: readonly string[];
63
+ /** HLL sketches, kept in aggregates of their own. */
64
+ readonly distinct: readonly string[];
65
+ /** Fixed once data exists. */
66
+ readonly shards: number;
67
+ readonly indexes: Readonly<Record<string, IndexDefinition>>;
68
+ /** On an identity field; a change to a row past it is dropped. */
69
+ readonly retention?: {
70
+ readonly field: string;
71
+ readonly days: number;
72
+ };
73
+ }
74
+ type ModelShape = TableShape | AggregateShape;
75
+ //#endregion
76
+ export { AggregateShape, DerivedShape, FieldDefinition, FieldReference, FieldType, IndexDefinition, ModelShape, ReferenceAction, TableShape };
@@ -0,0 +1,37 @@
1
+ //#region src/serverPlugin/errors.ts
2
+ var DatabaseConstraintError = class extends Error {
3
+ reason;
4
+ model;
5
+ name = "DatabaseConstraintError";
6
+ constructor(reason, model) {
7
+ super(`${model}: ${reason}`);
8
+ this.reason = reason;
9
+ this.model = model;
10
+ }
11
+ };
12
+ /** The retry budget ran out; ingestion answers 503 with Retry-After. */
13
+ var DatabaseConflictError = class extends Error {
14
+ name = "DatabaseConflictError";
15
+ };
16
+ /** The write may or may not have committed; it is reported, never rerun. */
17
+ var DatabaseAmbiguousCommitError = class extends Error {
18
+ name = "DatabaseAmbiguousCommitError";
19
+ };
20
+ var DatabaseTransactionError = class extends Error {
21
+ name = "DatabaseTransactionError";
22
+ };
23
+ /** A read that does not fit its model, such as an unknown index, a missing `where` field, or an out-of-range limit. */
24
+ var DatabaseQueryError = class extends Error {
25
+ name = "DatabaseQueryError";
26
+ };
27
+ /** A malformed cursor, or one from a read with another model, index, filter, order, or range. */
28
+ var DatabaseCursorError = class extends Error {
29
+ name = "DatabaseCursorError";
30
+ };
31
+ //#endregion
32
+ exports.DatabaseAmbiguousCommitError = DatabaseAmbiguousCommitError;
33
+ exports.DatabaseConflictError = DatabaseConflictError;
34
+ exports.DatabaseConstraintError = DatabaseConstraintError;
35
+ exports.DatabaseCursorError = DatabaseCursorError;
36
+ exports.DatabaseQueryError = DatabaseQueryError;
37
+ exports.DatabaseTransactionError = DatabaseTransactionError;
@@ -0,0 +1,29 @@
1
+ //#region src/serverPlugin/errors.d.ts
2
+ type ConstraintReason = "exists" | "unique" | "not_found" | "referenced" | "too_large";
3
+ declare class DatabaseConstraintError extends Error {
4
+ readonly reason: ConstraintReason;
5
+ readonly model: string;
6
+ readonly name = "DatabaseConstraintError";
7
+ constructor(reason: ConstraintReason, model: string);
8
+ }
9
+ /** The retry budget ran out; ingestion answers 503 with Retry-After. */
10
+ declare class DatabaseConflictError extends Error {
11
+ readonly name = "DatabaseConflictError";
12
+ }
13
+ /** The write may or may not have committed; it is reported, never rerun. */
14
+ declare class DatabaseAmbiguousCommitError extends Error {
15
+ readonly name = "DatabaseAmbiguousCommitError";
16
+ }
17
+ declare class DatabaseTransactionError extends Error {
18
+ readonly name = "DatabaseTransactionError";
19
+ }
20
+ /** A read that does not fit its model, such as an unknown index, a missing `where` field, or an out-of-range limit. */
21
+ declare class DatabaseQueryError extends Error {
22
+ readonly name = "DatabaseQueryError";
23
+ }
24
+ /** A malformed cursor, or one from a read with another model, index, filter, order, or range. */
25
+ declare class DatabaseCursorError extends Error {
26
+ readonly name = "DatabaseCursorError";
27
+ }
28
+ //#endregion
29
+ export { ConstraintReason, DatabaseAmbiguousCommitError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseTransactionError };
@@ -0,0 +1,29 @@
1
+ //#region src/serverPlugin/errors.d.ts
2
+ type ConstraintReason = "exists" | "unique" | "not_found" | "referenced" | "too_large";
3
+ declare class DatabaseConstraintError extends Error {
4
+ readonly reason: ConstraintReason;
5
+ readonly model: string;
6
+ readonly name = "DatabaseConstraintError";
7
+ constructor(reason: ConstraintReason, model: string);
8
+ }
9
+ /** The retry budget ran out; ingestion answers 503 with Retry-After. */
10
+ declare class DatabaseConflictError extends Error {
11
+ readonly name = "DatabaseConflictError";
12
+ }
13
+ /** The write may or may not have committed; it is reported, never rerun. */
14
+ declare class DatabaseAmbiguousCommitError extends Error {
15
+ readonly name = "DatabaseAmbiguousCommitError";
16
+ }
17
+ declare class DatabaseTransactionError extends Error {
18
+ readonly name = "DatabaseTransactionError";
19
+ }
20
+ /** A read that does not fit its model, such as an unknown index, a missing `where` field, or an out-of-range limit. */
21
+ declare class DatabaseQueryError extends Error {
22
+ readonly name = "DatabaseQueryError";
23
+ }
24
+ /** A malformed cursor, or one from a read with another model, index, filter, order, or range. */
25
+ declare class DatabaseCursorError extends Error {
26
+ readonly name = "DatabaseCursorError";
27
+ }
28
+ //#endregion
29
+ export { ConstraintReason, DatabaseAmbiguousCommitError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseTransactionError };
@@ -0,0 +1,32 @@
1
+ //#region src/serverPlugin/errors.ts
2
+ var DatabaseConstraintError = class extends Error {
3
+ reason;
4
+ model;
5
+ name = "DatabaseConstraintError";
6
+ constructor(reason, model) {
7
+ super(`${model}: ${reason}`);
8
+ this.reason = reason;
9
+ this.model = model;
10
+ }
11
+ };
12
+ /** The retry budget ran out; ingestion answers 503 with Retry-After. */
13
+ var DatabaseConflictError = class extends Error {
14
+ name = "DatabaseConflictError";
15
+ };
16
+ /** The write may or may not have committed; it is reported, never rerun. */
17
+ var DatabaseAmbiguousCommitError = class extends Error {
18
+ name = "DatabaseAmbiguousCommitError";
19
+ };
20
+ var DatabaseTransactionError = class extends Error {
21
+ name = "DatabaseTransactionError";
22
+ };
23
+ /** A read that does not fit its model, such as an unknown index, a missing `where` field, or an out-of-range limit. */
24
+ var DatabaseQueryError = class extends Error {
25
+ name = "DatabaseQueryError";
26
+ };
27
+ /** A malformed cursor, or one from a read with another model, index, filter, order, or range. */
28
+ var DatabaseCursorError = class extends Error {
29
+ name = "DatabaseCursorError";
30
+ };
31
+ //#endregion
32
+ export { DatabaseAmbiguousCommitError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, DatabaseQueryError, DatabaseTransactionError };
@@ -0,0 +1,24 @@
1
+ //#region src/serverPlugin/schema.ts
2
+ const defineTable = (fields, options) => ({
3
+ kind: "table",
4
+ fields,
5
+ key: options.key,
6
+ derived: options.derived ?? {},
7
+ indexes: options.indexes ?? {},
8
+ ...options.retention === void 0 ? {} : { retention: options.retention }
9
+ });
10
+ const defineAggregate = (fields, options) => ({
11
+ kind: "aggregate",
12
+ fields,
13
+ key: options.key,
14
+ counters: options.counters ?? [],
15
+ gauges: options.gauges ?? [],
16
+ distinct: options.distinct ?? [],
17
+ shards: options.shards ?? 1,
18
+ indexes: options.indexes ?? {},
19
+ ...options.batched ? { batched: true } : {},
20
+ ...options.retention === void 0 ? {} : { retention: options.retention }
21
+ });
22
+ //#endregion
23
+ exports.defineAggregate = defineAggregate;
24
+ exports.defineTable = defineTable;
@@ -0,0 +1,90 @@
1
+ import { DatabaseJson } from "../database/adapter.cjs";
2
+ import { AggregateShape, FieldDefinition, FieldReference, FieldType, IndexDefinition, ReferenceAction, TableShape } from "./definitions.cjs";
3
+ //#region src/serverPlugin/schema.d.ts
4
+ /**
5
+ * How long a model keeps its rows: `days` past the epoch milliseconds in
6
+ * `field`, an integer field (a table's derived one too, where null keeps
7
+ * the row). Expired rows are deleted without cascades, so a model with
8
+ * retention is in no reference and no rooted index.
9
+ */
10
+ interface RetentionDefinition<TField extends string = string> {
11
+ readonly field: TField;
12
+ readonly days: number;
13
+ }
14
+ type FieldValue<TType extends FieldType> = TType extends "string" ? string : TType extends "integer" | "number" ? number : TType extends "boolean" ? boolean : DatabaseJson;
15
+ type Fields = Readonly<Record<string, FieldDefinition>>;
16
+ type RowOf<TFields extends Fields> = { -readonly [K in keyof TFields]: TFields[K] extends FieldDefinition<infer TType> ? TFields[K] extends {
17
+ readonly required: false;
18
+ } ? FieldValue<TType> | null : FieldValue<TType> : never; };
19
+ /** Computed on every write and stored as a real column. */
20
+ interface DerivedDefinition<TRow = never, TType extends FieldType = FieldType> {
21
+ readonly type: TType;
22
+ /** Up to 16 values; the row is indexed once per value. */
23
+ readonly multi?: true;
24
+ /** Null, or an empty list, leaves the row out of indexes on this field. */
25
+ compute(row: TRow): FieldValue<TType> | null | readonly FieldValue<TType>[];
26
+ }
27
+ type DerivedTypes = Readonly<Record<string, FieldType>>;
28
+ /** Derived fields over a table's row, by name. */
29
+ type DerivedFields<TFields extends Fields, TDerived extends DerivedTypes> = { readonly [K in keyof TDerived]: DerivedDefinition<RowOf<TFields>, TDerived[K]>; };
30
+ type Indexes = Readonly<Record<string, IndexDefinition>>;
31
+ /** The integer fields, declared or derived, that retention can count from. */
32
+ type IntegerFields<TFields extends Fields, TDerived extends DerivedTypes> = { [K in keyof TFields]: TFields[K] extends {
33
+ readonly type: "integer";
34
+ } ? K : never; }[keyof TFields] | { [K in keyof TDerived]: TDerived[K] extends "integer" ? K : never; }[keyof TDerived];
35
+ type MissingFields<TIndex, TNames extends string> = TIndex extends {
36
+ readonly eq: readonly (infer TEq)[];
37
+ readonly sort: readonly (infer TSort)[];
38
+ } ? Exclude<TEq | TSort, TNames> : never;
39
+ /** Maps an index to an error message when it names an undeclared field. */
40
+ type CheckIndex<TName extends PropertyKey, TIndex, TNames extends string> = [MissingFields<TIndex, TNames>] extends [never] ? TIndex : `Index "${TName & string}" names undeclared field "${MissingFields<TIndex, TNames> & string}"`;
41
+ type CheckIndexes<TIndexes, TNames extends string> = { readonly [K in keyof TIndexes]: CheckIndex<K, TIndexes[K], TNames>; };
42
+ interface TableDefinition<TFields extends Fields = Fields, TDerived extends DerivedTypes = DerivedTypes, TIndexes extends Indexes = Indexes, TKey extends readonly (keyof TFields & string)[] = readonly (keyof TFields & string)[]> extends TableShape {
43
+ readonly kind: "table";
44
+ readonly fields: TFields;
45
+ readonly key: TKey;
46
+ readonly derived: DerivedFields<TFields, TDerived>;
47
+ readonly indexes: TIndexes;
48
+ }
49
+ declare const defineTable: <const TFields extends Fields, const TKey extends readonly (keyof TFields & string)[], const TDerived extends DerivedTypes = {}, const TIndexes extends Indexes = {}>(fields: TFields, options: {
50
+ readonly key: TKey;
51
+ readonly derived?: DerivedFields<TFields, TDerived>;
52
+ readonly indexes?: TIndexes & CheckIndexes<TIndexes, (keyof TFields | keyof TDerived) & string>;
53
+ /** Rows expire `days` after the epoch milliseconds in `field`. */
54
+ readonly retention?: RetentionDefinition<IntegerFields<TFields, TDerived> & string>;
55
+ }) => TableDefinition<TFields, TDerived, TIndexes, TKey>;
56
+ interface AggregateDefinition<TFields extends Fields = Fields, TMetric extends string = string, TIndexes extends Indexes = Indexes, TSketch extends string = string, TKey extends readonly (keyof TFields & string)[] = readonly (keyof TFields & string)[]> extends AggregateShape {
57
+ readonly kind: "aggregate";
58
+ readonly fields: TFields;
59
+ readonly key: TKey;
60
+ readonly counters: readonly TMetric[];
61
+ readonly gauges: readonly TMetric[];
62
+ readonly distinct: readonly TSketch[];
63
+ readonly indexes: TIndexes;
64
+ /**
65
+ * On a database that batches aggregates, changes apply after their
66
+ * transaction commits, in one write per row with other transactions'
67
+ * changes, so reads may lag them. Elsewhere they commit with it.
68
+ */
69
+ readonly batched?: true;
70
+ }
71
+ declare const defineAggregate: <const TFields extends Fields, const TKey extends readonly (keyof TFields & string)[], const TMetric extends string = never, const TIndexes extends Indexes = {}, const TSketch extends string = never>(fields: TFields, options: {
72
+ readonly key: TKey;
73
+ readonly counters?: readonly TMetric[];
74
+ readonly gauges?: readonly TMetric[];
75
+ readonly distinct?: readonly TSketch[];
76
+ readonly shards?: number;
77
+ readonly indexes?: TIndexes & CheckIndexes<TIndexes, keyof TFields & string>;
78
+ readonly batched?: true;
79
+ /**
80
+ * Rows expire `days` after the epoch milliseconds in `field`, an
81
+ * identity field such as a bucket's start; a change to a row already
82
+ * past it is dropped, so a late gauge decrement never goes below zero.
83
+ */
84
+ readonly retention?: RetentionDefinition<IntegerFields<TFields, {}> & string>;
85
+ }) => AggregateDefinition<TFields, TMetric, TIndexes, TSketch, TKey>;
86
+ type ModelDefinition = TableDefinition | AggregateDefinition;
87
+ /** A module's models by name: core, or one plugin. */
88
+ type ModuleSchema = Readonly<Record<string, ModelDefinition>>;
89
+ //#endregion
90
+ export { AggregateDefinition, CheckIndex, DerivedDefinition, DerivedFields, type FieldDefinition, type FieldReference, type FieldType, FieldValue, type IndexDefinition, ModelDefinition, ModuleSchema, type ReferenceAction, RetentionDefinition, RowOf, TableDefinition, defineAggregate, defineTable };