@hot-updater/plugin-core 0.36.7 → 1.0.0-rc.1

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 (161) hide show
  1. package/dist/assetStorageLayout.cjs +36 -18
  2. package/dist/assetStorageLayout.d.cts +21 -6
  3. package/dist/assetStorageLayout.d.mts +21 -6
  4. package/dist/assetStorageLayout.mjs +36 -18
  5. package/dist/bundleStorageLayout.cjs +2 -3
  6. package/dist/bundleStorageLayout.mjs +2 -3
  7. package/dist/contentAddressedAssets.cjs +5 -0
  8. package/dist/contentAddressedAssets.d.cts +2 -1
  9. package/dist/contentAddressedAssets.d.mts +2 -1
  10. package/dist/contentAddressedAssets.mjs +5 -1
  11. package/dist/createDatabasePlugin.cjs +775 -284
  12. package/dist/createDatabasePlugin.d.cts +20 -64
  13. package/dist/createDatabasePlugin.d.mts +20 -64
  14. package/dist/createDatabasePlugin.mjs +773 -284
  15. package/dist/createStorageKeyBuilder.cjs +9 -2
  16. package/dist/createStorageKeyBuilder.mjs +9 -2
  17. package/dist/createStoragePlugin.cjs +6 -145
  18. package/dist/createStoragePlugin.d.cts +7 -52
  19. package/dist/createStoragePlugin.d.mts +7 -52
  20. package/dist/createStoragePlugin.mjs +5 -143
  21. package/dist/databaseClient.cjs +112 -0
  22. package/dist/databaseClient.d.cts +33 -0
  23. package/dist/databaseClient.d.mts +33 -0
  24. package/dist/databaseClient.mjs +110 -0
  25. package/dist/databaseClientReads.cjs +113 -0
  26. package/dist/databaseClientReads.mjs +112 -0
  27. package/dist/databaseClientUpdates.cjs +39 -0
  28. package/dist/databaseClientUpdates.d.cts +11 -0
  29. package/dist/databaseClientUpdates.d.mts +11 -0
  30. package/dist/databaseClientUpdates.mjs +36 -0
  31. package/dist/databaseJsonValue.cjs +37 -0
  32. package/dist/databaseJsonValue.d.cts +5 -0
  33. package/dist/databaseJsonValue.d.mts +5 -0
  34. package/dist/databaseJsonValue.mjs +37 -0
  35. package/dist/databaseMetadata.cjs +13 -0
  36. package/dist/databaseMetadata.mjs +12 -0
  37. package/dist/databasePluginCrud.cjs +86 -0
  38. package/dist/databasePluginCrud.d.cts +1 -0
  39. package/dist/databasePluginCrud.d.mts +1 -0
  40. package/dist/databasePluginCrud.mjs +86 -0
  41. package/dist/databasePluginCrudValidation.d.cts +1 -0
  42. package/dist/databasePluginCrudValidation.d.mts +1 -0
  43. package/dist/databasePluginCrudValidationErrors.cjs +10 -0
  44. package/dist/databasePluginCrudValidationErrors.d.cts +9 -0
  45. package/dist/databasePluginCrudValidationErrors.d.mts +9 -0
  46. package/dist/databasePluginCrudValidationErrors.mjs +10 -0
  47. package/dist/databasePluginCrudValidationFields.cjs +291 -0
  48. package/dist/databasePluginCrudValidationFields.d.cts +1 -0
  49. package/dist/databasePluginCrudValidationFields.d.mts +1 -0
  50. package/dist/databasePluginCrudValidationFields.mjs +281 -0
  51. package/dist/databasePluginCrudValidationMutations.cjs +88 -0
  52. package/dist/databasePluginCrudValidationMutations.d.cts +1 -0
  53. package/dist/databasePluginCrudValidationMutations.d.mts +1 -0
  54. package/dist/databasePluginCrudValidationMutations.mjs +82 -0
  55. package/dist/databasePluginCrudValidationQueries.cjs +103 -0
  56. package/dist/databasePluginCrudValidationQueries.d.cts +1 -0
  57. package/dist/databasePluginCrudValidationQueries.d.mts +1 -0
  58. package/dist/databasePluginCrudValidationQueries.mjs +97 -0
  59. package/dist/databasePluginCrudValidationRows.cjs +55 -0
  60. package/dist/databasePluginCrudValidationRows.d.cts +1 -0
  61. package/dist/databasePluginCrudValidationRows.d.mts +1 -0
  62. package/dist/databasePluginCrudValidationRows.mjs +53 -0
  63. package/dist/databasePluginTransaction.cjs +7 -0
  64. package/dist/databasePluginTransaction.mjs +7 -0
  65. package/dist/databaseRows.cjs +149 -0
  66. package/dist/databaseRows.d.cts +34 -0
  67. package/dist/databaseRows.d.mts +34 -0
  68. package/dist/databaseRows.mjs +141 -0
  69. package/dist/index.cjs +76 -24
  70. package/dist/index.d.cts +22 -12
  71. package/dist/index.d.mts +22 -12
  72. package/dist/index.mjs +21 -14
  73. package/dist/internal.cjs +6 -0
  74. package/dist/internal.d.cts +9 -0
  75. package/dist/internal.d.mts +9 -0
  76. package/dist/internal.mjs +3 -0
  77. package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.cjs +345 -0
  78. package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.mjs +341 -0
  79. package/dist/paginateBundles.d.cts +6 -4
  80. package/dist/paginateBundles.d.mts +6 -4
  81. package/dist/parseStorageUri.cjs +46 -30
  82. package/dist/parseStorageUri.d.cts +20 -17
  83. package/dist/parseStorageUri.d.mts +20 -17
  84. package/dist/parseStorageUri.mjs +46 -30
  85. package/dist/queryBundles.cjs +1 -7
  86. package/dist/queryBundles.d.cts +3 -1
  87. package/dist/queryBundles.d.mts +3 -1
  88. package/dist/queryBundles.mjs +1 -7
  89. package/dist/releaseCatalogCompiler.cjs +391 -0
  90. package/dist/releaseCatalogCompiler.d.cts +55 -0
  91. package/dist/releaseCatalogCompiler.d.mts +55 -0
  92. package/dist/releaseCatalogCompiler.mjs +386 -0
  93. package/dist/releaseCatalogMutation.cjs +303 -0
  94. package/dist/releaseCatalogMutation.d.cts +86 -0
  95. package/dist/releaseCatalogMutation.d.mts +86 -0
  96. package/dist/releaseCatalogMutation.mjs +297 -0
  97. package/dist/releaseManagement.cjs +231 -0
  98. package/dist/releaseManagement.d.cts +48 -0
  99. package/dist/releaseManagement.d.mts +48 -0
  100. package/dist/releaseManagement.mjs +224 -0
  101. package/dist/remoteBundleSigning.cjs +294 -0
  102. package/dist/remoteBundleSigning.d.cts +41 -0
  103. package/dist/remoteBundleSigning.d.mts +41 -0
  104. package/dist/remoteBundleSigning.mjs +289 -0
  105. package/dist/requestBundleCache.cjs +22 -0
  106. package/dist/requestBundleCache.d.cts +9 -0
  107. package/dist/requestBundleCache.d.mts +9 -0
  108. package/dist/requestBundleCache.mjs +22 -0
  109. package/dist/semverSatisfies.cjs +3 -4
  110. package/dist/semverSatisfies.mjs +1 -1
  111. package/dist/storageDownloadPath.cjs +48 -0
  112. package/dist/storageDownloadPath.d.cts +15 -0
  113. package/dist/storageDownloadPath.d.mts +15 -0
  114. package/dist/storageDownloadPath.mjs +46 -0
  115. package/dist/types/database.d.cts +4 -0
  116. package/dist/types/database.d.mts +4 -0
  117. package/dist/types/databaseFields.cjs +92 -0
  118. package/dist/types/databaseFields.d.cts +12 -0
  119. package/dist/types/databaseFields.d.mts +12 -0
  120. package/dist/types/databaseFields.mjs +92 -0
  121. package/dist/types/databaseOperations.d.cts +173 -0
  122. package/dist/types/databaseOperations.d.mts +173 -0
  123. package/dist/types/databasePlugin.d.cts +240 -0
  124. package/dist/types/databasePlugin.d.mts +240 -0
  125. package/dist/types/databaseQuery.d.cts +47 -0
  126. package/dist/types/databaseQuery.d.mts +47 -0
  127. package/dist/types/databaseRows.d.cts +120 -0
  128. package/dist/types/databaseRows.d.mts +120 -0
  129. package/dist/types/index.d.cts +119 -161
  130. package/dist/types/index.d.mts +119 -161
  131. package/dist/types/internal.d.cts +7 -0
  132. package/dist/types/internal.d.mts +7 -0
  133. package/dist/types/public.d.cts +3 -0
  134. package/dist/types/public.d.mts +3 -0
  135. package/dist/uuidv7.cjs +9 -0
  136. package/dist/uuidv7.d.cts +4 -1
  137. package/dist/uuidv7.d.mts +4 -1
  138. package/dist/uuidv7.mjs +8 -1
  139. package/package.json +10 -5
  140. package/dist/bundleUnitOfWork.cjs +0 -158
  141. package/dist/bundleUnitOfWork.mjs +0 -158
  142. package/dist/bundleUnitOfWorkStore.cjs +0 -15
  143. package/dist/bundleUnitOfWorkStore.mjs +0 -15
  144. package/dist/createBlobDatabasePlugin.cjs +0 -382
  145. package/dist/createBlobDatabasePlugin.d.cts +0 -29
  146. package/dist/createBlobDatabasePlugin.d.mts +0 -29
  147. package/dist/createBlobDatabasePlugin.mjs +0 -381
  148. package/dist/legacyAssetStorageLayout.cjs +0 -12
  149. package/dist/legacyAssetStorageLayout.mjs +0 -12
  150. package/dist/requestUpdateBundleState.cjs +0 -26
  151. package/dist/requestUpdateBundleState.d.cts +0 -12
  152. package/dist/requestUpdateBundleState.d.mts +0 -12
  153. package/dist/requestUpdateBundleState.mjs +0 -24
  154. package/dist/resolveUpdateInfoFromBundles.cjs +0 -14
  155. package/dist/resolveUpdateInfoFromBundles.d.cts +0 -16
  156. package/dist/resolveUpdateInfoFromBundles.d.mts +0 -16
  157. package/dist/resolveUpdateInfoFromBundles.mjs +0 -13
  158. package/dist/storageProfile.cjs +0 -15
  159. package/dist/storageProfile.d.cts +0 -9
  160. package/dist/storageProfile.d.mts +0 -9
  161. package/dist/storageProfile.mjs +0 -12
@@ -0,0 +1,86 @@
1
+ import { DatabasePluginInputError } from "./databasePluginCrudValidationErrors.mjs";
2
+ import { validateModel } from "./databasePluginCrudValidationFields.mjs";
3
+ import { selectRow, validateCreateData, validateResult } from "./databasePluginCrudValidationRows.mjs";
4
+ import { validateApiKeyUpdateData, validateBundleUpdateData, validateMutationWhere, validateReleaseCatalogUpdateData, validateReleaseTargetUpdate, validateReleaseUpdateData, validateUpdateWhere } from "./databasePluginCrudValidationMutations.mjs";
5
+ import { validateDistinctFields, validateDistinctOn, validateOrderBy, validatePagination, validateSelect, validateWhere } from "./databasePluginCrudValidationQueries.mjs";
6
+ //#region src/databasePluginCrud.ts
7
+ const createDatabasePluginCrud = (implementation) => {
8
+ async function create(input) {
9
+ validateModel(input.model);
10
+ validateCreateData(input.model, input.data);
11
+ if (input.onConflict !== void 0 && !(input.onConflict === "ignore" && (input.model === "channels" || input.model === "api_keys"))) throw new DatabasePluginInputError("invalid-operation");
12
+ validateSelect(input.model, input.select);
13
+ const row = await implementation.create(input);
14
+ validateResult(input.model, row, input.select);
15
+ return selectRow(row, input);
16
+ }
17
+ async function update(input) {
18
+ validateModel(input.model);
19
+ validateWhere(input.model, input.where);
20
+ validateMutationWhere(input.where);
21
+ validateUpdateWhere(input.model, input.where);
22
+ if (input.model === "bundles") validateBundleUpdateData(input.update);
23
+ else if (input.model === "releases") validateReleaseUpdateData(input.update);
24
+ else if (input.model === "release_catalogs") validateReleaseCatalogUpdateData(input.update);
25
+ else if (input.model === "api_keys") validateApiKeyUpdateData(input.update);
26
+ else throw new DatabasePluginInputError("invalid-operation");
27
+ validateSelect(input.model, input.select);
28
+ if (input.model === "bundles") {} else if (input.model === "releases") await validateReleaseTargetUpdate(implementation, input);
29
+ const row = await implementation.update(input);
30
+ if (row === null) return null;
31
+ validateResult(input.model, row, input.select);
32
+ return selectRow(row, input);
33
+ }
34
+ async function deleteRows(input) {
35
+ validateModel(input.model);
36
+ if (input.model !== "bundles" && input.model !== "bundle_patches" && input.model !== "releases" && input.model !== "channels") throw new DatabasePluginInputError("invalid-operation");
37
+ validateWhere(input.model, input.where);
38
+ validateMutationWhere(input.where);
39
+ await implementation.delete(input);
40
+ }
41
+ async function count(input) {
42
+ validateModel(input.model);
43
+ validateWhere(input.model, input.where);
44
+ validateDistinctFields(input.model, input.distinct);
45
+ const value = await implementation.count(input);
46
+ if (!Number.isSafeInteger(value) || value < 0) throw new DatabasePluginInputError("invalid-result");
47
+ return value;
48
+ }
49
+ async function findOne(input) {
50
+ validateModel(input.model);
51
+ validateWhere(input.model, input.where);
52
+ validateSelect(input.model, input.select);
53
+ const row = await implementation.findOne(input);
54
+ if (row === null) return null;
55
+ validateResult(input.model, row, input.select);
56
+ return selectRow(row, input);
57
+ }
58
+ async function findMany(input) {
59
+ validateModel(input.model);
60
+ validateWhere(input.model, input.where);
61
+ validatePagination(input.limit, input.offset);
62
+ validateSelect(input.model, input.select);
63
+ const validatedOrderBy = validateOrderBy(input.model, input.orderBy);
64
+ validateDistinctOn(input.model, input.distinctOn, validatedOrderBy);
65
+ const normalizedInput = {
66
+ ...input,
67
+ orderBy: input.orderBy,
68
+ limit: input.limit ?? 100,
69
+ offset: input.offset ?? 0
70
+ };
71
+ const rows = await implementation.findMany(normalizedInput);
72
+ if (!Array.isArray(rows)) throw new DatabasePluginInputError("invalid-result");
73
+ rows.forEach((row) => validateResult(input.model, row, input.select));
74
+ return rows.map((row) => selectRow(row, input));
75
+ }
76
+ return {
77
+ create,
78
+ update,
79
+ delete: deleteRows,
80
+ count,
81
+ findOne,
82
+ findMany
83
+ };
84
+ };
85
+ //#endregion
86
+ export { createDatabasePluginCrud };
@@ -0,0 +1 @@
1
+ import { DatabasePluginInputError, DatabasePluginInputErrorCode } from "./databasePluginCrudValidationErrors.cjs";
@@ -0,0 +1 @@
1
+ import { DatabasePluginInputError, DatabasePluginInputErrorCode } from "./databasePluginCrudValidationErrors.mjs";
@@ -0,0 +1,10 @@
1
+ //#region src/databasePluginCrudValidationErrors.ts
2
+ var DatabasePluginInputError = class extends Error {
3
+ name = "DatabasePluginInputError";
4
+ constructor(code) {
5
+ super(`Invalid database plugin input: ${code}`);
6
+ this.code = code;
7
+ }
8
+ };
9
+ //#endregion
10
+ exports.DatabasePluginInputError = DatabasePluginInputError;
@@ -0,0 +1,9 @@
1
+ //#region src/databasePluginCrudValidationErrors.d.ts
2
+ type DatabasePluginInputErrorCode = "empty-mutation-where" | "empty-select" | "invalid-data" | "invalid-distinct" | "invalid-field" | "invalid-model" | "invalid-operation" | "invalid-query" | "invalid-result" | "invalid-pagination" | "invalid-update-selector";
3
+ declare class DatabasePluginInputError extends Error {
4
+ readonly code: DatabasePluginInputErrorCode;
5
+ readonly name = "DatabasePluginInputError";
6
+ constructor(code: DatabasePluginInputErrorCode);
7
+ }
8
+ //#endregion
9
+ export { DatabasePluginInputError, DatabasePluginInputErrorCode };
@@ -0,0 +1,9 @@
1
+ //#region src/databasePluginCrudValidationErrors.d.ts
2
+ type DatabasePluginInputErrorCode = "empty-mutation-where" | "empty-select" | "invalid-data" | "invalid-distinct" | "invalid-field" | "invalid-model" | "invalid-operation" | "invalid-query" | "invalid-result" | "invalid-pagination" | "invalid-update-selector";
3
+ declare class DatabasePluginInputError extends Error {
4
+ readonly code: DatabasePluginInputErrorCode;
5
+ readonly name = "DatabasePluginInputError";
6
+ constructor(code: DatabasePluginInputErrorCode);
7
+ }
8
+ //#endregion
9
+ export { DatabasePluginInputError, DatabasePluginInputErrorCode };
@@ -0,0 +1,10 @@
1
+ //#region src/databasePluginCrudValidationErrors.ts
2
+ var DatabasePluginInputError = class extends Error {
3
+ name = "DatabasePluginInputError";
4
+ constructor(code) {
5
+ super(`Invalid database plugin input: ${code}`);
6
+ this.code = code;
7
+ }
8
+ };
9
+ //#endregion
10
+ export { DatabasePluginInputError };
@@ -0,0 +1,291 @@
1
+ require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_databasePluginCrudValidationErrors = require("./databasePluginCrudValidationErrors.cjs");
3
+ const require_databaseJsonValue = require("./databaseJsonValue.cjs");
4
+ const require_databaseFields = require("./types/databaseFields.cjs");
5
+ let _hot_updater_core = require("@hot-updater/core");
6
+ //#region src/databasePluginCrudValidationFields.ts
7
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
+ const isChannelText = (value) => {
9
+ if (typeof value !== "string" || value.length === 0) return false;
10
+ let codePointCount = 0;
11
+ for (const _codePoint of value) {
12
+ codePointCount += 1;
13
+ if (codePointCount > 255) return false;
14
+ }
15
+ return true;
16
+ };
17
+ const modelValidators = {
18
+ bundles: {
19
+ id: (value) => typeof value === "string",
20
+ platform: (value) => value === "ios" || value === "android",
21
+ should_force_update: (value) => typeof value === "boolean",
22
+ enabled: (value) => typeof value === "boolean",
23
+ file_hash: (value) => typeof value === "string",
24
+ git_commit_hash: (value) => value === null || typeof value === "string",
25
+ message: (value) => value === null || typeof value === "string",
26
+ channel: isChannelText,
27
+ channel_id: isChannelText,
28
+ storage_uri: (value) => typeof value === "string",
29
+ archive_byte_size: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0,
30
+ target_app_version: (value) => value === null || typeof value === "string",
31
+ fingerprint_hash: (value) => value === null || typeof value === "string",
32
+ metadata: require_databaseJsonValue.isDatabaseMetadataObject,
33
+ rollout_cohort_count: (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 1e3,
34
+ target_cohorts: (value) => value === null || Array.isArray(value) && value.every((item) => typeof item === "string"),
35
+ manifest_storage_uri: (value) => value === null || typeof value === "string",
36
+ manifest_file_hash: (value) => value === null || typeof value === "string",
37
+ asset_base_storage_uri: (value) => value === null || typeof value === "string"
38
+ },
39
+ bundle_patches: {
40
+ id: (value) => typeof value === "string",
41
+ bundle_id: (value) => typeof value === "string",
42
+ base_bundle_id: (value) => typeof value === "string",
43
+ base_file_hash: (value) => typeof value === "string",
44
+ patch_file_hash: (value) => typeof value === "string",
45
+ patch_storage_uri: (value) => typeof value === "string",
46
+ byte_size: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0,
47
+ order_index: (value) => typeof value === "number" && Number.isInteger(value) && value >= 0
48
+ },
49
+ releases: {
50
+ id: _hot_updater_core.isUUIDv7,
51
+ revision: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1,
52
+ scope_key: (value) => typeof value === "string" && value.length > 0,
53
+ channel_id: isChannelText,
54
+ platform: (value) => value === "ios" || value === "android",
55
+ kind: (value) => value === "BUNDLE" || value === "EMBEDDED",
56
+ bundle_id: (value) => value === null || typeof value === "string",
57
+ strategy: (value) => value === "APP_VERSION" || value === "FINGERPRINT",
58
+ target_app_version: (value) => value === null || typeof value === "string",
59
+ fingerprint_hash: (value) => value === null || typeof value === "string",
60
+ enabled: (value) => typeof value === "boolean",
61
+ should_force_update: (value) => typeof value === "boolean",
62
+ message: (value) => value === null || typeof value === "string",
63
+ rollout_cohort_count: (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 1e3,
64
+ target_cohorts: (value) => Array.isArray(value) && value.every((item) => typeof item === "string"),
65
+ operation: (value) => value === "DEPLOY" || value === "PROMOTE" || value === "ROLLBACK",
66
+ source_release_id: (value) => value === null || (0, _hot_updater_core.isUUIDv7)(value),
67
+ created_at_ms: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0,
68
+ updated_at_ms: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0
69
+ },
70
+ release_catalogs: {
71
+ scope_key: (value) => typeof value === "string" && value.length > 0,
72
+ catalog_id: (value) => typeof value === "string" && value.length > 0,
73
+ strategy: (value) => value === "APP_VERSION" || value === "FINGERPRINT",
74
+ channel_id: isChannelText,
75
+ channel_key: (value) => typeof value === "string" && value.length > 0,
76
+ platform: (value) => value === "ios" || value === "android",
77
+ fingerprint_hash: (value) => value === null || typeof value === "string",
78
+ generation: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1,
79
+ payload: (value) => typeof value === "string",
80
+ catalog_hash: (value) => typeof value === "string" && value.length > 0,
81
+ byte_size: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0,
82
+ is_tombstone: (value) => typeof value === "boolean",
83
+ updated_at_ms: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0
84
+ },
85
+ channels: {
86
+ id: isChannelText,
87
+ name: isChannelText
88
+ },
89
+ bundle_events: {
90
+ id: (value) => typeof value === "string",
91
+ type: (value) => value === "UPDATE_APPLIED" || value === "RECOVERED" || value === "RELEASE_ADOPTED" || value === "UNCHANGED",
92
+ install_id: (value) => typeof value === "string",
93
+ user_id: (value) => value === null || typeof value === "string",
94
+ username: (value) => value === null || typeof value === "string",
95
+ from_bundle_id: (value) => value === null || typeof value === "string",
96
+ from_release_id: (value) => value === null || typeof value === "string",
97
+ to_release_id: (value) => value === null || typeof value === "string",
98
+ to_bundle_id: (value) => typeof value === "string",
99
+ platform: (value) => value === "ios" || value === "android",
100
+ app_version: (value) => typeof value === "string",
101
+ channel: (value) => typeof value === "string",
102
+ cohort: (value) => typeof value === "string",
103
+ update_strategy: (value) => value === null || value === "fingerprint" || value === "appVersion",
104
+ fingerprint_hash: (value) => value === null || typeof value === "string",
105
+ sdk_version: (value) => value === null || typeof value === "string",
106
+ received_at_ms: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0
107
+ },
108
+ api_keys: {
109
+ id: (value) => typeof value === "string",
110
+ hash: (value) => typeof value === "string",
111
+ name: (value) => typeof value === "string",
112
+ prefix: (value) => typeof value === "string",
113
+ role: (value) => value === "client",
114
+ created_at_ms: (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0,
115
+ revoked_at_ms: (value) => value === null || typeof value === "number" && Number.isSafeInteger(value) && value >= 0
116
+ }
117
+ };
118
+ const stringFields = new Set([
119
+ "id",
120
+ "platform",
121
+ "file_hash",
122
+ "git_commit_hash",
123
+ "message",
124
+ "channel",
125
+ "channel_id",
126
+ "storage_uri",
127
+ "target_app_version",
128
+ "fingerprint_hash",
129
+ "bundle_id",
130
+ "base_bundle_id",
131
+ "base_file_hash",
132
+ "patch_file_hash",
133
+ "patch_storage_uri",
134
+ "scope_key",
135
+ "catalog_id",
136
+ "channel_key",
137
+ "kind",
138
+ "bundle_id",
139
+ "strategy",
140
+ "operation",
141
+ "source_release_id",
142
+ "payload",
143
+ "catalog_hash",
144
+ "type",
145
+ "install_id",
146
+ "user_id",
147
+ "username",
148
+ "from_bundle_id",
149
+ "to_bundle_id",
150
+ "app_version",
151
+ "cohort",
152
+ "update_strategy",
153
+ "sdk_version",
154
+ "hash",
155
+ "name",
156
+ "prefix",
157
+ "role"
158
+ ]);
159
+ const numberFields = new Set([
160
+ "archive_byte_size",
161
+ "byte_size",
162
+ "rollout_cohort_count",
163
+ "order_index",
164
+ "revision",
165
+ "generation",
166
+ "byte_size",
167
+ "updated_at_ms",
168
+ "received_at_ms",
169
+ "created_at_ms",
170
+ "revoked_at_ms"
171
+ ]);
172
+ const booleanFields = new Set([
173
+ "should_force_update",
174
+ "enabled",
175
+ "is_tombstone"
176
+ ]);
177
+ const sortableFields = {
178
+ bundles: new Set([
179
+ "id",
180
+ "platform",
181
+ "file_hash",
182
+ "git_commit_hash",
183
+ "message",
184
+ "channel",
185
+ "channel_id",
186
+ "storage_uri",
187
+ "archive_byte_size",
188
+ "target_app_version",
189
+ "fingerprint_hash",
190
+ "rollout_cohort_count",
191
+ "manifest_storage_uri",
192
+ "manifest_file_hash",
193
+ "asset_base_storage_uri"
194
+ ]),
195
+ bundle_patches: new Set([
196
+ "id",
197
+ "bundle_id",
198
+ "base_bundle_id",
199
+ "base_file_hash",
200
+ "patch_file_hash",
201
+ "patch_storage_uri",
202
+ "byte_size",
203
+ "order_index"
204
+ ]),
205
+ releases: new Set([
206
+ "id",
207
+ "revision",
208
+ "scope_key",
209
+ "channel_id",
210
+ "platform",
211
+ "kind",
212
+ "bundle_id",
213
+ "strategy",
214
+ "target_app_version",
215
+ "fingerprint_hash",
216
+ "enabled",
217
+ "should_force_update",
218
+ "message",
219
+ "rollout_cohort_count",
220
+ "operation",
221
+ "source_release_id",
222
+ "created_at_ms",
223
+ "updated_at_ms"
224
+ ]),
225
+ release_catalogs: new Set([
226
+ "scope_key",
227
+ "catalog_id",
228
+ "strategy",
229
+ "channel_id",
230
+ "channel_key",
231
+ "platform",
232
+ "fingerprint_hash",
233
+ "generation",
234
+ "catalog_hash",
235
+ "byte_size",
236
+ "is_tombstone",
237
+ "updated_at_ms"
238
+ ]),
239
+ channels: new Set(["id", "name"]),
240
+ bundle_events: new Set([
241
+ "id",
242
+ "type",
243
+ "install_id",
244
+ "user_id",
245
+ "username",
246
+ "from_bundle_id",
247
+ "from_release_id",
248
+ "to_release_id",
249
+ "to_bundle_id",
250
+ "platform",
251
+ "app_version",
252
+ "channel",
253
+ "cohort",
254
+ "update_strategy",
255
+ "fingerprint_hash",
256
+ "sdk_version",
257
+ "received_at_ms"
258
+ ]),
259
+ api_keys: new Set([
260
+ "id",
261
+ "hash",
262
+ "name",
263
+ "prefix",
264
+ "role",
265
+ "created_at_ms",
266
+ "revoked_at_ms"
267
+ ])
268
+ };
269
+ const validateModel = (model) => {
270
+ if (typeof model !== "string" || !Object.hasOwn(require_databaseFields.databaseFields, model)) throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-model");
271
+ };
272
+ const validateField = (model, field) => {
273
+ if (!require_databaseFields.databaseFields[model].includes(field)) throw new require_databasePluginCrudValidationErrors.DatabasePluginInputError("invalid-field");
274
+ };
275
+ const validateFields = (model, fields) => {
276
+ for (const field of fields) validateField(model, field);
277
+ };
278
+ const isStringField = (field) => stringFields.has(field);
279
+ const isNumberField = (field) => numberFields.has(field);
280
+ const isBooleanField = (field) => booleanFields.has(field);
281
+ //#endregion
282
+ exports.isBooleanField = isBooleanField;
283
+ exports.isChannelText = isChannelText;
284
+ exports.isNumberField = isNumberField;
285
+ exports.isRecord = isRecord;
286
+ exports.isStringField = isStringField;
287
+ exports.modelValidators = modelValidators;
288
+ exports.sortableFields = sortableFields;
289
+ exports.validateField = validateField;
290
+ exports.validateFields = validateFields;
291
+ exports.validateModel = validateModel;
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };