@hot-updater/plugin-core 0.36.7 → 1.0.0-rc.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/dist/assetStorageLayout.cjs +36 -18
- package/dist/assetStorageLayout.d.cts +21 -6
- package/dist/assetStorageLayout.d.mts +21 -6
- package/dist/assetStorageLayout.mjs +36 -18
- package/dist/bundleStorageLayout.cjs +2 -3
- package/dist/bundleStorageLayout.mjs +2 -3
- package/dist/contentAddressedAssets.cjs +5 -0
- package/dist/contentAddressedAssets.d.cts +2 -1
- package/dist/contentAddressedAssets.d.mts +2 -1
- package/dist/contentAddressedAssets.mjs +5 -1
- package/dist/createDatabasePlugin.cjs +775 -284
- package/dist/createDatabasePlugin.d.cts +20 -64
- package/dist/createDatabasePlugin.d.mts +20 -64
- package/dist/createDatabasePlugin.mjs +773 -284
- package/dist/createStorageKeyBuilder.cjs +9 -2
- package/dist/createStorageKeyBuilder.mjs +9 -2
- package/dist/createStoragePlugin.cjs +6 -145
- package/dist/createStoragePlugin.d.cts +7 -52
- package/dist/createStoragePlugin.d.mts +7 -52
- package/dist/createStoragePlugin.mjs +5 -143
- package/dist/databaseClient.cjs +112 -0
- package/dist/databaseClient.d.cts +33 -0
- package/dist/databaseClient.d.mts +33 -0
- package/dist/databaseClient.mjs +110 -0
- package/dist/databaseClientReads.cjs +113 -0
- package/dist/databaseClientReads.mjs +112 -0
- package/dist/databaseClientUpdates.cjs +39 -0
- package/dist/databaseClientUpdates.d.cts +11 -0
- package/dist/databaseClientUpdates.d.mts +11 -0
- package/dist/databaseClientUpdates.mjs +36 -0
- package/dist/databaseJsonValue.cjs +37 -0
- package/dist/databaseJsonValue.d.cts +5 -0
- package/dist/databaseJsonValue.d.mts +5 -0
- package/dist/databaseJsonValue.mjs +37 -0
- package/dist/databaseMetadata.cjs +13 -0
- package/dist/databaseMetadata.mjs +12 -0
- package/dist/databasePluginCrud.cjs +86 -0
- package/dist/databasePluginCrud.d.cts +1 -0
- package/dist/databasePluginCrud.d.mts +1 -0
- package/dist/databasePluginCrud.mjs +86 -0
- package/dist/databasePluginCrudValidation.d.cts +1 -0
- package/dist/databasePluginCrudValidation.d.mts +1 -0
- package/dist/databasePluginCrudValidationErrors.cjs +10 -0
- package/dist/databasePluginCrudValidationErrors.d.cts +9 -0
- package/dist/databasePluginCrudValidationErrors.d.mts +9 -0
- package/dist/databasePluginCrudValidationErrors.mjs +10 -0
- package/dist/databasePluginCrudValidationFields.cjs +291 -0
- package/dist/databasePluginCrudValidationFields.d.cts +1 -0
- package/dist/databasePluginCrudValidationFields.d.mts +1 -0
- package/dist/databasePluginCrudValidationFields.mjs +281 -0
- package/dist/databasePluginCrudValidationMutations.cjs +88 -0
- package/dist/databasePluginCrudValidationMutations.d.cts +1 -0
- package/dist/databasePluginCrudValidationMutations.d.mts +1 -0
- package/dist/databasePluginCrudValidationMutations.mjs +82 -0
- package/dist/databasePluginCrudValidationQueries.cjs +103 -0
- package/dist/databasePluginCrudValidationQueries.d.cts +1 -0
- package/dist/databasePluginCrudValidationQueries.d.mts +1 -0
- package/dist/databasePluginCrudValidationQueries.mjs +97 -0
- package/dist/databasePluginCrudValidationRows.cjs +55 -0
- package/dist/databasePluginCrudValidationRows.d.cts +1 -0
- package/dist/databasePluginCrudValidationRows.d.mts +1 -0
- package/dist/databasePluginCrudValidationRows.mjs +53 -0
- package/dist/databasePluginTransaction.cjs +7 -0
- package/dist/databasePluginTransaction.mjs +7 -0
- package/dist/databaseRows.cjs +149 -0
- package/dist/databaseRows.d.cts +34 -0
- package/dist/databaseRows.d.mts +34 -0
- package/dist/databaseRows.mjs +141 -0
- package/dist/index.cjs +76 -24
- package/dist/index.d.cts +22 -12
- package/dist/index.d.mts +22 -12
- package/dist/index.mjs +21 -14
- package/dist/internal.cjs +6 -0
- package/dist/internal.d.cts +9 -0
- package/dist/internal.d.mts +9 -0
- package/dist/internal.mjs +3 -0
- package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.cjs +345 -0
- package/dist/node_modules/.pnpm/verkit@0.3.2/node_modules/verkit/dist/index.mjs +341 -0
- package/dist/paginateBundles.d.cts +6 -4
- package/dist/paginateBundles.d.mts +6 -4
- package/dist/parseStorageUri.cjs +46 -30
- package/dist/parseStorageUri.d.cts +20 -17
- package/dist/parseStorageUri.d.mts +20 -17
- package/dist/parseStorageUri.mjs +46 -30
- package/dist/queryBundles.cjs +1 -7
- package/dist/queryBundles.d.cts +3 -1
- package/dist/queryBundles.d.mts +3 -1
- package/dist/queryBundles.mjs +1 -7
- package/dist/releaseCatalogCompiler.cjs +391 -0
- package/dist/releaseCatalogCompiler.d.cts +55 -0
- package/dist/releaseCatalogCompiler.d.mts +55 -0
- package/dist/releaseCatalogCompiler.mjs +386 -0
- package/dist/releaseCatalogMutation.cjs +303 -0
- package/dist/releaseCatalogMutation.d.cts +86 -0
- package/dist/releaseCatalogMutation.d.mts +86 -0
- package/dist/releaseCatalogMutation.mjs +297 -0
- package/dist/releaseManagement.cjs +231 -0
- package/dist/releaseManagement.d.cts +48 -0
- package/dist/releaseManagement.d.mts +48 -0
- package/dist/releaseManagement.mjs +224 -0
- package/dist/remoteBundleSigning.cjs +296 -0
- package/dist/remoteBundleSigning.d.cts +43 -0
- package/dist/remoteBundleSigning.d.mts +43 -0
- package/dist/remoteBundleSigning.mjs +291 -0
- package/dist/requestBundleCache.cjs +22 -0
- package/dist/requestBundleCache.d.cts +9 -0
- package/dist/requestBundleCache.d.mts +9 -0
- package/dist/requestBundleCache.mjs +22 -0
- package/dist/semverSatisfies.cjs +3 -4
- package/dist/semverSatisfies.mjs +1 -1
- package/dist/storageDownloadPath.cjs +48 -0
- package/dist/storageDownloadPath.d.cts +15 -0
- package/dist/storageDownloadPath.d.mts +15 -0
- package/dist/storageDownloadPath.mjs +46 -0
- package/dist/types/database.d.cts +4 -0
- package/dist/types/database.d.mts +4 -0
- package/dist/types/databaseFields.cjs +92 -0
- package/dist/types/databaseFields.d.cts +12 -0
- package/dist/types/databaseFields.d.mts +12 -0
- package/dist/types/databaseFields.mjs +92 -0
- package/dist/types/databaseOperations.d.cts +173 -0
- package/dist/types/databaseOperations.d.mts +173 -0
- package/dist/types/databasePlugin.d.cts +240 -0
- package/dist/types/databasePlugin.d.mts +240 -0
- package/dist/types/databaseQuery.d.cts +47 -0
- package/dist/types/databaseQuery.d.mts +47 -0
- package/dist/types/databaseRows.d.cts +120 -0
- package/dist/types/databaseRows.d.mts +120 -0
- package/dist/types/index.d.cts +120 -162
- package/dist/types/index.d.mts +120 -162
- package/dist/types/internal.d.cts +7 -0
- package/dist/types/internal.d.mts +7 -0
- package/dist/types/public.d.cts +3 -0
- package/dist/types/public.d.mts +3 -0
- package/dist/uuidv7.cjs +9 -0
- package/dist/uuidv7.d.cts +4 -1
- package/dist/uuidv7.d.mts +4 -1
- package/dist/uuidv7.mjs +8 -1
- package/package.json +10 -5
- package/dist/bundleUnitOfWork.cjs +0 -158
- package/dist/bundleUnitOfWork.mjs +0 -158
- package/dist/bundleUnitOfWorkStore.cjs +0 -15
- package/dist/bundleUnitOfWorkStore.mjs +0 -15
- package/dist/createBlobDatabasePlugin.cjs +0 -382
- package/dist/createBlobDatabasePlugin.d.cts +0 -29
- package/dist/createBlobDatabasePlugin.d.mts +0 -29
- package/dist/createBlobDatabasePlugin.mjs +0 -381
- package/dist/legacyAssetStorageLayout.cjs +0 -12
- package/dist/legacyAssetStorageLayout.mjs +0 -12
- package/dist/requestUpdateBundleState.cjs +0 -26
- package/dist/requestUpdateBundleState.d.cts +0 -12
- package/dist/requestUpdateBundleState.d.mts +0 -12
- package/dist/requestUpdateBundleState.mjs +0 -24
- package/dist/resolveUpdateInfoFromBundles.cjs +0 -14
- package/dist/resolveUpdateInfoFromBundles.d.cts +0 -16
- package/dist/resolveUpdateInfoFromBundles.d.mts +0 -16
- package/dist/resolveUpdateInfoFromBundles.mjs +0 -13
- package/dist/storageProfile.cjs +0 -15
- package/dist/storageProfile.d.cts +0 -9
- package/dist/storageProfile.d.mts +0 -9
- package/dist/storageProfile.mjs +0 -12
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { ApiKeyRow, BundleRow, DatabaseModel, DatabaseRow, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
|
|
2
|
+
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, DatabaseCommit, DatabaseCommitResult } from "./databasePlugin.mjs";
|
|
3
|
+
import { DatabaseDistinctFields, DatabaseDistinctOn, DatabaseOrderBy, DatabaseSelect, DatabaseWhere, SelectedDatabaseRow } from "./databaseQuery.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/types/databaseOperations.d.ts
|
|
6
|
+
type DatabaseCapability = "create" | "update" | "delete" | "count" | "findOne" | "findMany";
|
|
7
|
+
type DatabaseModelCapabilities = {
|
|
8
|
+
readonly bundles: {
|
|
9
|
+
readonly create: true;
|
|
10
|
+
readonly update: true;
|
|
11
|
+
readonly delete: true;
|
|
12
|
+
readonly count: true;
|
|
13
|
+
readonly findOne: true;
|
|
14
|
+
readonly findMany: true;
|
|
15
|
+
};
|
|
16
|
+
readonly bundle_patches: {
|
|
17
|
+
readonly create: true;
|
|
18
|
+
readonly update: false;
|
|
19
|
+
readonly delete: true;
|
|
20
|
+
readonly count: true;
|
|
21
|
+
readonly findOne: true;
|
|
22
|
+
readonly findMany: true;
|
|
23
|
+
};
|
|
24
|
+
readonly releases: {
|
|
25
|
+
readonly create: true;
|
|
26
|
+
readonly update: true;
|
|
27
|
+
readonly delete: true;
|
|
28
|
+
readonly count: true;
|
|
29
|
+
readonly findOne: true;
|
|
30
|
+
readonly findMany: true;
|
|
31
|
+
};
|
|
32
|
+
readonly release_catalogs: {
|
|
33
|
+
readonly create: true;
|
|
34
|
+
readonly update: true;
|
|
35
|
+
readonly delete: false;
|
|
36
|
+
readonly count: false;
|
|
37
|
+
readonly findOne: true;
|
|
38
|
+
readonly findMany: true;
|
|
39
|
+
};
|
|
40
|
+
readonly channels: {
|
|
41
|
+
readonly create: true;
|
|
42
|
+
readonly update: false;
|
|
43
|
+
readonly delete: true;
|
|
44
|
+
readonly count: false;
|
|
45
|
+
readonly findOne: true;
|
|
46
|
+
readonly findMany: true;
|
|
47
|
+
};
|
|
48
|
+
readonly bundle_events: {
|
|
49
|
+
readonly create: true;
|
|
50
|
+
readonly update: false;
|
|
51
|
+
readonly delete: false;
|
|
52
|
+
readonly count: false;
|
|
53
|
+
readonly findOne: false;
|
|
54
|
+
readonly findMany: true;
|
|
55
|
+
};
|
|
56
|
+
readonly api_keys: {
|
|
57
|
+
readonly create: true;
|
|
58
|
+
readonly update: true;
|
|
59
|
+
readonly delete: false;
|
|
60
|
+
readonly count: false;
|
|
61
|
+
readonly findOne: true;
|
|
62
|
+
readonly findMany: true;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
type DatabaseModelsWithCapability<TCapability extends DatabaseCapability> = { readonly [TModel in DatabaseModel]: DatabaseModelCapabilities[TModel][TCapability] extends true ? TModel : never }[DatabaseModel];
|
|
66
|
+
type CreateDatabaseModel = DatabaseModelsWithCapability<"create">;
|
|
67
|
+
type UpdateDatabaseModel = DatabaseModelsWithCapability<"update">;
|
|
68
|
+
type DeleteDatabaseModel = DatabaseModelsWithCapability<"delete">;
|
|
69
|
+
type CountDatabaseModel = DatabaseModelsWithCapability<"count">;
|
|
70
|
+
type FindOneDatabaseModel = DatabaseModelsWithCapability<"findOne">;
|
|
71
|
+
type FindManyDatabaseModel = DatabaseModelsWithCapability<"findMany">;
|
|
72
|
+
type DatabaseDeleteModel = DeleteDatabaseModel;
|
|
73
|
+
type DatabaseFindOneModel = FindOneDatabaseModel;
|
|
74
|
+
type CreateDatabaseInputBase<TModel extends CreateDatabaseModel, TSelect extends DatabaseSelect<TModel> | undefined = undefined> = {
|
|
75
|
+
readonly model: TModel;
|
|
76
|
+
readonly data: DatabaseRow<TModel>;
|
|
77
|
+
readonly select?: TSelect;
|
|
78
|
+
};
|
|
79
|
+
type CreateDatabaseInput<TModel extends CreateDatabaseModel, TSelect extends DatabaseSelect<TModel> | undefined = undefined> = CreateDatabaseInputBase<TModel, TSelect> & (TModel extends "channels" | "api_keys" ? {
|
|
80
|
+
readonly onConflict?: "ignore";
|
|
81
|
+
} : {
|
|
82
|
+
readonly onConflict?: never;
|
|
83
|
+
});
|
|
84
|
+
type BundleRowUpdateFields = Partial<Omit<BundleRow, "id">>;
|
|
85
|
+
type ReleaseRowUpdate = Partial<Pick<ReleaseRow, "revision" | "scope_key" | "target_app_version" | "fingerprint_hash" | "enabled" | "should_force_update" | "message" | "rollout_cohort_count" | "target_cohorts" | "updated_at_ms">>;
|
|
86
|
+
type ReleaseCatalogRowUpdate = Omit<ReleaseCatalogRow, "scope_key">;
|
|
87
|
+
type BundleRowUpdate = BundleRowUpdateFields;
|
|
88
|
+
type ApiKeyRowUpdate = Pick<ApiKeyRow, "revoked_at_ms">;
|
|
89
|
+
type DatabaseRowUpdate<TModel extends UpdateDatabaseModel> = {
|
|
90
|
+
readonly bundles: BundleRowUpdate;
|
|
91
|
+
readonly releases: ReleaseRowUpdate;
|
|
92
|
+
readonly release_catalogs: ReleaseCatalogRowUpdate;
|
|
93
|
+
readonly api_keys: ApiKeyRowUpdate;
|
|
94
|
+
}[TModel];
|
|
95
|
+
type UpdateDatabaseInput<TModel extends UpdateDatabaseModel, TSelect extends DatabaseSelect<TModel> | undefined = undefined> = {
|
|
96
|
+
readonly model: TModel;
|
|
97
|
+
readonly where: readonly DatabaseWhere<TModel>[];
|
|
98
|
+
readonly update: DatabaseRowUpdate<TModel>;
|
|
99
|
+
readonly select?: TSelect;
|
|
100
|
+
};
|
|
101
|
+
type UpdateBundleDatabaseInput<TSelect extends DatabaseSelect<"bundles"> | undefined = undefined> = UpdateDatabaseInput<"bundles", TSelect>;
|
|
102
|
+
type DeleteDatabaseInput<TModel extends DeleteDatabaseModel> = {
|
|
103
|
+
readonly model: TModel;
|
|
104
|
+
readonly where: readonly DatabaseWhere<TModel>[];
|
|
105
|
+
};
|
|
106
|
+
type CountDatabaseInput<TModel extends CountDatabaseModel> = {
|
|
107
|
+
readonly model: TModel;
|
|
108
|
+
readonly where?: readonly DatabaseWhere<TModel>[];
|
|
109
|
+
readonly distinct?: DatabaseDistinctFields<TModel>;
|
|
110
|
+
};
|
|
111
|
+
type CountBundlesDatabaseInput = CountDatabaseInput<"bundles">;
|
|
112
|
+
type FindOneDatabaseInput<TModel extends FindOneDatabaseModel, TSelect extends DatabaseSelect<TModel> | undefined = undefined> = {
|
|
113
|
+
readonly model: TModel;
|
|
114
|
+
readonly where?: readonly DatabaseWhere<TModel>[];
|
|
115
|
+
readonly select?: TSelect;
|
|
116
|
+
};
|
|
117
|
+
type FindManyDatabaseInput<TModel extends FindManyDatabaseModel, TSelect extends DatabaseSelect<TModel> | undefined = undefined> = {
|
|
118
|
+
readonly model: TModel;
|
|
119
|
+
readonly where?: readonly DatabaseWhere<TModel>[];
|
|
120
|
+
readonly limit?: number;
|
|
121
|
+
readonly offset?: number;
|
|
122
|
+
readonly orderBy?: DatabaseOrderBy<TModel>;
|
|
123
|
+
readonly distinctOn?: DatabaseDistinctOn<TModel>;
|
|
124
|
+
readonly select?: TSelect;
|
|
125
|
+
};
|
|
126
|
+
type SelectedDatabaseInputRow<TInput extends {
|
|
127
|
+
readonly model: DatabaseModel;
|
|
128
|
+
readonly select?: readonly string[] | undefined;
|
|
129
|
+
}> = SelectedDatabaseRow<TInput["model"], "select" extends keyof TInput ? Extract<TInput["select"], DatabaseSelect<TInput["model"]> | undefined> : undefined>;
|
|
130
|
+
interface DatabasePluginCrud {
|
|
131
|
+
create<TInput extends CreateDatabaseImplementationInput>(input: TInput): Promise<SelectedDatabaseInputRow<TInput>>;
|
|
132
|
+
update<TInput extends UpdateDatabaseImplementationInput>(input: TInput): Promise<SelectedDatabaseInputRow<TInput> | null>;
|
|
133
|
+
delete(input: DeleteDatabaseImplementationInput): Promise<void>;
|
|
134
|
+
count(input: CountDatabaseImplementationInput): Promise<number>;
|
|
135
|
+
findOne<TInput extends FindOneDatabaseImplementationInput>(input: TInput): Promise<SelectedDatabaseInputRow<TInput> | null>;
|
|
136
|
+
findMany<TInput extends FindManyDatabasePluginInput>(input: TInput): Promise<SelectedDatabaseInputRow<TInput>[]>;
|
|
137
|
+
}
|
|
138
|
+
type DatabaseImplementationResult = { readonly [TModel in DatabaseModel]: Partial<DatabaseRow<TModel>> }[DatabaseModel];
|
|
139
|
+
type CreateDatabaseImplementationInput = { readonly [TModel in CreateDatabaseModel]: CreateDatabaseInput<TModel, DatabaseSelect<TModel> | undefined> }[CreateDatabaseModel];
|
|
140
|
+
type UpdateDatabaseImplementationInput = { readonly [TModel in UpdateDatabaseModel]: UpdateDatabaseInput<TModel, DatabaseSelect<TModel> | undefined> }[UpdateDatabaseModel];
|
|
141
|
+
type DeleteDatabaseImplementationInput = { readonly [TModel in DeleteDatabaseModel]: DeleteDatabaseInput<TModel> }[DeleteDatabaseModel];
|
|
142
|
+
type CountDatabaseImplementationInput = { readonly [TModel in CountDatabaseModel]: CountDatabaseInput<TModel> }[CountDatabaseModel];
|
|
143
|
+
type UpdateBundleDatabaseImplementationInput = UpdateDatabaseInput<"bundles", DatabaseSelect<"bundles"> | undefined>;
|
|
144
|
+
type CountBundlesDatabaseImplementationInput = CountDatabaseInput<"bundles">;
|
|
145
|
+
type FindOneDatabaseImplementationInput = { readonly [TModel in FindOneDatabaseModel]: FindOneDatabaseInput<TModel, DatabaseSelect<TModel> | undefined> }[FindOneDatabaseModel];
|
|
146
|
+
type FindManyDatabaseImplementationInput = { readonly [TModel in FindManyDatabaseModel]: Omit<FindManyDatabaseInput<TModel, DatabaseSelect<TModel> | undefined>, "limit" | "offset"> & {
|
|
147
|
+
readonly limit: number;
|
|
148
|
+
readonly offset: number;
|
|
149
|
+
} }[FindManyDatabaseModel];
|
|
150
|
+
type FindManyDatabasePluginInput = { readonly [TModel in FindManyDatabaseModel]: FindManyDatabaseInput<TModel, DatabaseSelect<TModel> | undefined> }[FindManyDatabaseModel];
|
|
151
|
+
interface TransactionDatabasePluginImplementation {
|
|
152
|
+
create(input: CreateDatabaseImplementationInput): Promise<DatabaseImplementationResult>;
|
|
153
|
+
update(input: UpdateDatabaseImplementationInput): Promise<DatabaseImplementationResult | null>;
|
|
154
|
+
delete(input: DeleteDatabaseImplementationInput): Promise<void>;
|
|
155
|
+
count(input: CountDatabaseImplementationInput): Promise<number>;
|
|
156
|
+
findOne(input: FindOneDatabaseImplementationInput): Promise<DatabaseImplementationResult | null>;
|
|
157
|
+
findMany(input: FindManyDatabaseImplementationInput): Promise<readonly DatabaseImplementationResult[]>;
|
|
158
|
+
}
|
|
159
|
+
interface DatabasePluginImplementation {
|
|
160
|
+
create(input: CreateDatabaseImplementationInput): Promise<DatabaseImplementationResult>;
|
|
161
|
+
update(input: UpdateDatabaseImplementationInput): Promise<DatabaseImplementationResult | null>;
|
|
162
|
+
delete(input: DeleteDatabaseImplementationInput): Promise<void>;
|
|
163
|
+
count(input: CountDatabaseImplementationInput): Promise<number>;
|
|
164
|
+
findOne(input: FindOneDatabaseImplementationInput): Promise<DatabaseImplementationResult | null>;
|
|
165
|
+
findMany(input: FindManyDatabaseImplementationInput): Promise<readonly DatabaseImplementationResult[]>;
|
|
166
|
+
insertChannel(input: ChannelInsertInput): Promise<ChannelInsertResult>;
|
|
167
|
+
deleteChannel(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
|
|
168
|
+
transaction?: <TResult>(callback: (transaction: TransactionDatabasePluginImplementation) => Promise<TResult>) => Promise<TResult>;
|
|
169
|
+
commit?: (input: DatabaseCommit) => Promise<DatabaseCommitResult>;
|
|
170
|
+
dispose?: () => Promise<void>;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { ApiKeyRowUpdate, BundleRowUpdate, CountBundlesDatabaseImplementationInput, CountBundlesDatabaseInput, CountDatabaseImplementationInput, CountDatabaseInput, CountDatabaseModel, CreateDatabaseImplementationInput, CreateDatabaseInput, CreateDatabaseModel, DatabaseCapability, DatabaseDeleteModel, DatabaseFindOneModel, DatabaseImplementationResult, DatabaseModelCapabilities, DatabaseModelsWithCapability, DatabasePluginCrud, DatabasePluginImplementation, DatabaseRowUpdate, DeleteDatabaseImplementationInput, DeleteDatabaseInput, DeleteDatabaseModel, FindManyDatabaseImplementationInput, FindManyDatabaseInput, FindManyDatabaseModel, FindManyDatabasePluginInput, FindOneDatabaseImplementationInput, FindOneDatabaseInput, FindOneDatabaseModel, ReleaseCatalogRowUpdate, ReleaseRowUpdate, SelectedDatabaseInputRow, TransactionDatabasePluginImplementation, UpdateBundleDatabaseImplementationInput, UpdateBundleDatabaseInput, UpdateDatabaseImplementationInput, UpdateDatabaseInput, UpdateDatabaseModel };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ApiKeyRow, BundleEventRow, BundlePatchRow, BundleRow, ChannelRow, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.cjs";
|
|
2
|
+
import { BundleRowUpdate, ReleaseRowUpdate } from "./databaseOperations.cjs";
|
|
3
|
+
import { DatabaseBundleQueryOrder, DatabaseBundleQueryWhere } from "./index.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/types/databasePlugin.d.ts
|
|
6
|
+
interface BundleModelQuery {
|
|
7
|
+
readonly where?: DatabaseBundleQueryWhere;
|
|
8
|
+
readonly limit: number;
|
|
9
|
+
readonly offset: number;
|
|
10
|
+
readonly orderBy: DatabaseBundleQueryOrder;
|
|
11
|
+
}
|
|
12
|
+
interface BundleModel {
|
|
13
|
+
findById(id: string): Promise<BundleRow | null>;
|
|
14
|
+
findMany(query: BundleModelQuery): Promise<readonly BundleRow[]>;
|
|
15
|
+
count(where?: DatabaseBundleQueryWhere): Promise<number>;
|
|
16
|
+
}
|
|
17
|
+
interface BundlePatchModel {
|
|
18
|
+
findByBundleIds(bundleIds: readonly string[]): Promise<readonly BundlePatchRow[]>;
|
|
19
|
+
}
|
|
20
|
+
interface ReleaseModel {
|
|
21
|
+
findById(id: string): Promise<ReleaseRow | null>;
|
|
22
|
+
findMany(input: {
|
|
23
|
+
readonly afterReleaseId?: string;
|
|
24
|
+
readonly beforeReleaseId?: string;
|
|
25
|
+
readonly bundleId?: string;
|
|
26
|
+
readonly channelId?: string;
|
|
27
|
+
readonly enabled?: boolean;
|
|
28
|
+
readonly platform?: "ios" | "android";
|
|
29
|
+
readonly targetAppVersion?: string;
|
|
30
|
+
readonly limit: number;
|
|
31
|
+
}): Promise<readonly ReleaseRow[]>;
|
|
32
|
+
findManyByScope(input: {
|
|
33
|
+
readonly scopeKey: string;
|
|
34
|
+
readonly afterReleaseId?: string;
|
|
35
|
+
readonly limit: number;
|
|
36
|
+
readonly consistency: "strong";
|
|
37
|
+
}): Promise<readonly ReleaseRow[]>;
|
|
38
|
+
}
|
|
39
|
+
interface ReleaseCatalogModel {
|
|
40
|
+
findByScopeKey(scopeKey: string): Promise<ReleaseCatalogRow | null>;
|
|
41
|
+
findMany(input: {
|
|
42
|
+
readonly afterScopeKey?: string;
|
|
43
|
+
readonly limit: number;
|
|
44
|
+
}): Promise<readonly ReleaseCatalogRow[]>;
|
|
45
|
+
}
|
|
46
|
+
interface AnalyticsScanCursor {
|
|
47
|
+
readonly receivedAtMs: number;
|
|
48
|
+
readonly id: string;
|
|
49
|
+
}
|
|
50
|
+
interface AnalyticsScanInput {
|
|
51
|
+
readonly beforeReceivedAtMs: number;
|
|
52
|
+
readonly after?: AnalyticsScanCursor;
|
|
53
|
+
readonly limit: number;
|
|
54
|
+
}
|
|
55
|
+
interface AnalyticsModel {
|
|
56
|
+
append(row: BundleEventRow): Promise<void>;
|
|
57
|
+
scan(input: AnalyticsScanInput): Promise<readonly BundleEventRow[]>;
|
|
58
|
+
}
|
|
59
|
+
interface ApiKeyModel {
|
|
60
|
+
create(row: ApiKeyRow): Promise<"created" | "existing">;
|
|
61
|
+
findByHash(hash: string): Promise<ApiKeyRow | null>;
|
|
62
|
+
list(): Promise<readonly ApiKeyRow[]>;
|
|
63
|
+
revoke(input: {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly revokedAtMs: number;
|
|
66
|
+
}): Promise<ApiKeyRow | null>;
|
|
67
|
+
}
|
|
68
|
+
interface ChannelInsertInput {
|
|
69
|
+
readonly row: ChannelRow;
|
|
70
|
+
readonly onConflict: "returnExisting";
|
|
71
|
+
}
|
|
72
|
+
interface ChannelInsertResult {
|
|
73
|
+
readonly row: ChannelRow;
|
|
74
|
+
readonly inserted: boolean;
|
|
75
|
+
}
|
|
76
|
+
interface ChannelDeleteInput {
|
|
77
|
+
readonly id: string;
|
|
78
|
+
}
|
|
79
|
+
type ChannelDeleteResult = {
|
|
80
|
+
readonly deleted: true;
|
|
81
|
+
} | {
|
|
82
|
+
readonly deleted: false;
|
|
83
|
+
readonly reason: "not_found" | "not_empty";
|
|
84
|
+
};
|
|
85
|
+
interface ChannelModel {
|
|
86
|
+
insert(input: ChannelInsertInput): Promise<ChannelInsertResult>;
|
|
87
|
+
list(input: {}): Promise<{
|
|
88
|
+
readonly channels: readonly ChannelRow[];
|
|
89
|
+
}>;
|
|
90
|
+
delete(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
|
|
91
|
+
}
|
|
92
|
+
type DatabaseChange = {
|
|
93
|
+
readonly model: "bundles";
|
|
94
|
+
readonly operation: "insert";
|
|
95
|
+
readonly row: BundleRow;
|
|
96
|
+
} | {
|
|
97
|
+
readonly model: "bundles";
|
|
98
|
+
readonly operation: "update";
|
|
99
|
+
readonly where: {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
};
|
|
102
|
+
readonly update: BundleRowUpdate;
|
|
103
|
+
} | {
|
|
104
|
+
readonly model: "bundles";
|
|
105
|
+
readonly operation: "delete";
|
|
106
|
+
readonly where: {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
};
|
|
109
|
+
} | {
|
|
110
|
+
readonly model: "bundlePatches";
|
|
111
|
+
readonly operation: "insert";
|
|
112
|
+
readonly row: BundlePatchRow;
|
|
113
|
+
} | {
|
|
114
|
+
readonly model: "bundlePatches";
|
|
115
|
+
readonly operation: "delete";
|
|
116
|
+
readonly where: {
|
|
117
|
+
readonly bundleId: string;
|
|
118
|
+
};
|
|
119
|
+
} | {
|
|
120
|
+
readonly model: "releases";
|
|
121
|
+
readonly operation: "insert";
|
|
122
|
+
readonly row: ReleaseRow;
|
|
123
|
+
} | {
|
|
124
|
+
readonly model: "releases";
|
|
125
|
+
readonly operation: "update";
|
|
126
|
+
readonly where: {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
};
|
|
129
|
+
readonly update: ReleaseRowUpdate;
|
|
130
|
+
} | {
|
|
131
|
+
readonly model: "releases";
|
|
132
|
+
readonly operation: "delete";
|
|
133
|
+
readonly where: {
|
|
134
|
+
readonly id: string;
|
|
135
|
+
};
|
|
136
|
+
} | {
|
|
137
|
+
readonly model: "releaseCatalogs";
|
|
138
|
+
readonly operation: "put";
|
|
139
|
+
readonly row: ReleaseCatalogRow;
|
|
140
|
+
} | {
|
|
141
|
+
readonly model: "channels";
|
|
142
|
+
readonly operation: "insert";
|
|
143
|
+
readonly row: ChannelRow;
|
|
144
|
+
readonly onConflict: "ignore";
|
|
145
|
+
} | {
|
|
146
|
+
readonly model: "channels";
|
|
147
|
+
readonly operation: "delete";
|
|
148
|
+
readonly where: {
|
|
149
|
+
readonly id: string;
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
readonly model: "analytics";
|
|
153
|
+
readonly operation: "insert";
|
|
154
|
+
readonly row: BundleEventRow;
|
|
155
|
+
} | {
|
|
156
|
+
readonly model: "apiKeys";
|
|
157
|
+
readonly operation: "insert";
|
|
158
|
+
readonly row: ApiKeyRow;
|
|
159
|
+
readonly onConflict: "ignore";
|
|
160
|
+
} | {
|
|
161
|
+
readonly model: "apiKeys";
|
|
162
|
+
readonly operation: "update";
|
|
163
|
+
readonly where: {
|
|
164
|
+
readonly id: string;
|
|
165
|
+
};
|
|
166
|
+
readonly update: {
|
|
167
|
+
readonly revokedAtMs: number;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
type DatabaseCommitExpectation = {
|
|
171
|
+
readonly model: "releases";
|
|
172
|
+
readonly id: string;
|
|
173
|
+
readonly revision: number | null;
|
|
174
|
+
} | {
|
|
175
|
+
readonly model: "releaseCatalogs";
|
|
176
|
+
readonly scopeKey: string;
|
|
177
|
+
readonly generation: number | null;
|
|
178
|
+
};
|
|
179
|
+
interface DatabaseCommit {
|
|
180
|
+
readonly changes: readonly DatabaseChange[];
|
|
181
|
+
readonly expectations?: readonly DatabaseCommitExpectation[];
|
|
182
|
+
}
|
|
183
|
+
type BundleRepositoryBundleChange = Extract<DatabaseChange, {
|
|
184
|
+
readonly model: "bundles" | "bundlePatches";
|
|
185
|
+
}>;
|
|
186
|
+
type BundleRepositoryChannelChange = Extract<DatabaseChange, {
|
|
187
|
+
readonly model: "channels";
|
|
188
|
+
}>;
|
|
189
|
+
type BundleRepositoryChange = BundleRepositoryBundleChange | BundleRepositoryChannelChange;
|
|
190
|
+
/**
|
|
191
|
+
* The atomic envelopes supported by a bundle-management repository.
|
|
192
|
+
*
|
|
193
|
+
* Bundle and patch changes form one aggregate commit. Channel lifecycle is a
|
|
194
|
+
* separate single-change commit because the standalone HTTP boundary cannot
|
|
195
|
+
* atomically combine a Channel write with a bundle aggregate write.
|
|
196
|
+
*/
|
|
197
|
+
type BundleRepositoryCommit = {
|
|
198
|
+
readonly changes: readonly BundleRepositoryBundleChange[];
|
|
199
|
+
} | {
|
|
200
|
+
readonly changes: readonly [BundleRepositoryChannelChange];
|
|
201
|
+
};
|
|
202
|
+
type DatabaseCommitResult = {
|
|
203
|
+
readonly committed: true;
|
|
204
|
+
} | {
|
|
205
|
+
readonly committed: false;
|
|
206
|
+
readonly conflict: {
|
|
207
|
+
readonly changeIndex: number;
|
|
208
|
+
readonly reason: "not_found" | "referenced";
|
|
209
|
+
} | {
|
|
210
|
+
readonly changeIndex: -1;
|
|
211
|
+
readonly reason: "version_conflict";
|
|
212
|
+
readonly model: "releases" | "releaseCatalogs";
|
|
213
|
+
readonly key: string;
|
|
214
|
+
readonly expectedVersion: number | null;
|
|
215
|
+
readonly actualVersion: number | null;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
interface DatabaseModels {
|
|
219
|
+
readonly bundles: BundleModel;
|
|
220
|
+
readonly bundlePatches: BundlePatchModel;
|
|
221
|
+
readonly releases: ReleaseModel;
|
|
222
|
+
readonly releaseCatalogs: ReleaseCatalogModel;
|
|
223
|
+
readonly channels: ChannelModel;
|
|
224
|
+
readonly analytics: AnalyticsModel;
|
|
225
|
+
readonly apiKeys: ApiKeyModel;
|
|
226
|
+
}
|
|
227
|
+
interface BundleRepository {
|
|
228
|
+
readonly name: string;
|
|
229
|
+
readonly models: Pick<DatabaseModels, "bundles" | "bundlePatches" | "channels" | "releaseCatalogs" | "releases">;
|
|
230
|
+
commit(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
231
|
+
dispose?: () => Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
interface DatabasePlugin {
|
|
234
|
+
readonly name: string;
|
|
235
|
+
readonly models: DatabaseModels;
|
|
236
|
+
commit(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
237
|
+
dispose?: () => Promise<void>;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
export { AnalyticsModel, AnalyticsScanCursor, AnalyticsScanInput, ApiKeyModel, BundleModel, BundleModelQuery, BundlePatchModel, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, DatabaseChange, DatabaseCommit, DatabaseCommitExpectation, DatabaseCommitResult, DatabaseModels, DatabasePlugin, ReleaseCatalogModel, ReleaseModel };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ApiKeyRow, BundleEventRow, BundlePatchRow, BundleRow, ChannelRow, ReleaseCatalogRow, ReleaseRow } from "./databaseRows.mjs";
|
|
2
|
+
import { BundleRowUpdate, ReleaseRowUpdate } from "./databaseOperations.mjs";
|
|
3
|
+
import { DatabaseBundleQueryOrder, DatabaseBundleQueryWhere } from "./index.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/types/databasePlugin.d.ts
|
|
6
|
+
interface BundleModelQuery {
|
|
7
|
+
readonly where?: DatabaseBundleQueryWhere;
|
|
8
|
+
readonly limit: number;
|
|
9
|
+
readonly offset: number;
|
|
10
|
+
readonly orderBy: DatabaseBundleQueryOrder;
|
|
11
|
+
}
|
|
12
|
+
interface BundleModel {
|
|
13
|
+
findById(id: string): Promise<BundleRow | null>;
|
|
14
|
+
findMany(query: BundleModelQuery): Promise<readonly BundleRow[]>;
|
|
15
|
+
count(where?: DatabaseBundleQueryWhere): Promise<number>;
|
|
16
|
+
}
|
|
17
|
+
interface BundlePatchModel {
|
|
18
|
+
findByBundleIds(bundleIds: readonly string[]): Promise<readonly BundlePatchRow[]>;
|
|
19
|
+
}
|
|
20
|
+
interface ReleaseModel {
|
|
21
|
+
findById(id: string): Promise<ReleaseRow | null>;
|
|
22
|
+
findMany(input: {
|
|
23
|
+
readonly afterReleaseId?: string;
|
|
24
|
+
readonly beforeReleaseId?: string;
|
|
25
|
+
readonly bundleId?: string;
|
|
26
|
+
readonly channelId?: string;
|
|
27
|
+
readonly enabled?: boolean;
|
|
28
|
+
readonly platform?: "ios" | "android";
|
|
29
|
+
readonly targetAppVersion?: string;
|
|
30
|
+
readonly limit: number;
|
|
31
|
+
}): Promise<readonly ReleaseRow[]>;
|
|
32
|
+
findManyByScope(input: {
|
|
33
|
+
readonly scopeKey: string;
|
|
34
|
+
readonly afterReleaseId?: string;
|
|
35
|
+
readonly limit: number;
|
|
36
|
+
readonly consistency: "strong";
|
|
37
|
+
}): Promise<readonly ReleaseRow[]>;
|
|
38
|
+
}
|
|
39
|
+
interface ReleaseCatalogModel {
|
|
40
|
+
findByScopeKey(scopeKey: string): Promise<ReleaseCatalogRow | null>;
|
|
41
|
+
findMany(input: {
|
|
42
|
+
readonly afterScopeKey?: string;
|
|
43
|
+
readonly limit: number;
|
|
44
|
+
}): Promise<readonly ReleaseCatalogRow[]>;
|
|
45
|
+
}
|
|
46
|
+
interface AnalyticsScanCursor {
|
|
47
|
+
readonly receivedAtMs: number;
|
|
48
|
+
readonly id: string;
|
|
49
|
+
}
|
|
50
|
+
interface AnalyticsScanInput {
|
|
51
|
+
readonly beforeReceivedAtMs: number;
|
|
52
|
+
readonly after?: AnalyticsScanCursor;
|
|
53
|
+
readonly limit: number;
|
|
54
|
+
}
|
|
55
|
+
interface AnalyticsModel {
|
|
56
|
+
append(row: BundleEventRow): Promise<void>;
|
|
57
|
+
scan(input: AnalyticsScanInput): Promise<readonly BundleEventRow[]>;
|
|
58
|
+
}
|
|
59
|
+
interface ApiKeyModel {
|
|
60
|
+
create(row: ApiKeyRow): Promise<"created" | "existing">;
|
|
61
|
+
findByHash(hash: string): Promise<ApiKeyRow | null>;
|
|
62
|
+
list(): Promise<readonly ApiKeyRow[]>;
|
|
63
|
+
revoke(input: {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly revokedAtMs: number;
|
|
66
|
+
}): Promise<ApiKeyRow | null>;
|
|
67
|
+
}
|
|
68
|
+
interface ChannelInsertInput {
|
|
69
|
+
readonly row: ChannelRow;
|
|
70
|
+
readonly onConflict: "returnExisting";
|
|
71
|
+
}
|
|
72
|
+
interface ChannelInsertResult {
|
|
73
|
+
readonly row: ChannelRow;
|
|
74
|
+
readonly inserted: boolean;
|
|
75
|
+
}
|
|
76
|
+
interface ChannelDeleteInput {
|
|
77
|
+
readonly id: string;
|
|
78
|
+
}
|
|
79
|
+
type ChannelDeleteResult = {
|
|
80
|
+
readonly deleted: true;
|
|
81
|
+
} | {
|
|
82
|
+
readonly deleted: false;
|
|
83
|
+
readonly reason: "not_found" | "not_empty";
|
|
84
|
+
};
|
|
85
|
+
interface ChannelModel {
|
|
86
|
+
insert(input: ChannelInsertInput): Promise<ChannelInsertResult>;
|
|
87
|
+
list(input: {}): Promise<{
|
|
88
|
+
readonly channels: readonly ChannelRow[];
|
|
89
|
+
}>;
|
|
90
|
+
delete(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
|
|
91
|
+
}
|
|
92
|
+
type DatabaseChange = {
|
|
93
|
+
readonly model: "bundles";
|
|
94
|
+
readonly operation: "insert";
|
|
95
|
+
readonly row: BundleRow;
|
|
96
|
+
} | {
|
|
97
|
+
readonly model: "bundles";
|
|
98
|
+
readonly operation: "update";
|
|
99
|
+
readonly where: {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
};
|
|
102
|
+
readonly update: BundleRowUpdate;
|
|
103
|
+
} | {
|
|
104
|
+
readonly model: "bundles";
|
|
105
|
+
readonly operation: "delete";
|
|
106
|
+
readonly where: {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
};
|
|
109
|
+
} | {
|
|
110
|
+
readonly model: "bundlePatches";
|
|
111
|
+
readonly operation: "insert";
|
|
112
|
+
readonly row: BundlePatchRow;
|
|
113
|
+
} | {
|
|
114
|
+
readonly model: "bundlePatches";
|
|
115
|
+
readonly operation: "delete";
|
|
116
|
+
readonly where: {
|
|
117
|
+
readonly bundleId: string;
|
|
118
|
+
};
|
|
119
|
+
} | {
|
|
120
|
+
readonly model: "releases";
|
|
121
|
+
readonly operation: "insert";
|
|
122
|
+
readonly row: ReleaseRow;
|
|
123
|
+
} | {
|
|
124
|
+
readonly model: "releases";
|
|
125
|
+
readonly operation: "update";
|
|
126
|
+
readonly where: {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
};
|
|
129
|
+
readonly update: ReleaseRowUpdate;
|
|
130
|
+
} | {
|
|
131
|
+
readonly model: "releases";
|
|
132
|
+
readonly operation: "delete";
|
|
133
|
+
readonly where: {
|
|
134
|
+
readonly id: string;
|
|
135
|
+
};
|
|
136
|
+
} | {
|
|
137
|
+
readonly model: "releaseCatalogs";
|
|
138
|
+
readonly operation: "put";
|
|
139
|
+
readonly row: ReleaseCatalogRow;
|
|
140
|
+
} | {
|
|
141
|
+
readonly model: "channels";
|
|
142
|
+
readonly operation: "insert";
|
|
143
|
+
readonly row: ChannelRow;
|
|
144
|
+
readonly onConflict: "ignore";
|
|
145
|
+
} | {
|
|
146
|
+
readonly model: "channels";
|
|
147
|
+
readonly operation: "delete";
|
|
148
|
+
readonly where: {
|
|
149
|
+
readonly id: string;
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
readonly model: "analytics";
|
|
153
|
+
readonly operation: "insert";
|
|
154
|
+
readonly row: BundleEventRow;
|
|
155
|
+
} | {
|
|
156
|
+
readonly model: "apiKeys";
|
|
157
|
+
readonly operation: "insert";
|
|
158
|
+
readonly row: ApiKeyRow;
|
|
159
|
+
readonly onConflict: "ignore";
|
|
160
|
+
} | {
|
|
161
|
+
readonly model: "apiKeys";
|
|
162
|
+
readonly operation: "update";
|
|
163
|
+
readonly where: {
|
|
164
|
+
readonly id: string;
|
|
165
|
+
};
|
|
166
|
+
readonly update: {
|
|
167
|
+
readonly revokedAtMs: number;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
type DatabaseCommitExpectation = {
|
|
171
|
+
readonly model: "releases";
|
|
172
|
+
readonly id: string;
|
|
173
|
+
readonly revision: number | null;
|
|
174
|
+
} | {
|
|
175
|
+
readonly model: "releaseCatalogs";
|
|
176
|
+
readonly scopeKey: string;
|
|
177
|
+
readonly generation: number | null;
|
|
178
|
+
};
|
|
179
|
+
interface DatabaseCommit {
|
|
180
|
+
readonly changes: readonly DatabaseChange[];
|
|
181
|
+
readonly expectations?: readonly DatabaseCommitExpectation[];
|
|
182
|
+
}
|
|
183
|
+
type BundleRepositoryBundleChange = Extract<DatabaseChange, {
|
|
184
|
+
readonly model: "bundles" | "bundlePatches";
|
|
185
|
+
}>;
|
|
186
|
+
type BundleRepositoryChannelChange = Extract<DatabaseChange, {
|
|
187
|
+
readonly model: "channels";
|
|
188
|
+
}>;
|
|
189
|
+
type BundleRepositoryChange = BundleRepositoryBundleChange | BundleRepositoryChannelChange;
|
|
190
|
+
/**
|
|
191
|
+
* The atomic envelopes supported by a bundle-management repository.
|
|
192
|
+
*
|
|
193
|
+
* Bundle and patch changes form one aggregate commit. Channel lifecycle is a
|
|
194
|
+
* separate single-change commit because the standalone HTTP boundary cannot
|
|
195
|
+
* atomically combine a Channel write with a bundle aggregate write.
|
|
196
|
+
*/
|
|
197
|
+
type BundleRepositoryCommit = {
|
|
198
|
+
readonly changes: readonly BundleRepositoryBundleChange[];
|
|
199
|
+
} | {
|
|
200
|
+
readonly changes: readonly [BundleRepositoryChannelChange];
|
|
201
|
+
};
|
|
202
|
+
type DatabaseCommitResult = {
|
|
203
|
+
readonly committed: true;
|
|
204
|
+
} | {
|
|
205
|
+
readonly committed: false;
|
|
206
|
+
readonly conflict: {
|
|
207
|
+
readonly changeIndex: number;
|
|
208
|
+
readonly reason: "not_found" | "referenced";
|
|
209
|
+
} | {
|
|
210
|
+
readonly changeIndex: -1;
|
|
211
|
+
readonly reason: "version_conflict";
|
|
212
|
+
readonly model: "releases" | "releaseCatalogs";
|
|
213
|
+
readonly key: string;
|
|
214
|
+
readonly expectedVersion: number | null;
|
|
215
|
+
readonly actualVersion: number | null;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
interface DatabaseModels {
|
|
219
|
+
readonly bundles: BundleModel;
|
|
220
|
+
readonly bundlePatches: BundlePatchModel;
|
|
221
|
+
readonly releases: ReleaseModel;
|
|
222
|
+
readonly releaseCatalogs: ReleaseCatalogModel;
|
|
223
|
+
readonly channels: ChannelModel;
|
|
224
|
+
readonly analytics: AnalyticsModel;
|
|
225
|
+
readonly apiKeys: ApiKeyModel;
|
|
226
|
+
}
|
|
227
|
+
interface BundleRepository {
|
|
228
|
+
readonly name: string;
|
|
229
|
+
readonly models: Pick<DatabaseModels, "bundles" | "bundlePatches" | "channels" | "releaseCatalogs" | "releases">;
|
|
230
|
+
commit(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
231
|
+
dispose?: () => Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
interface DatabasePlugin {
|
|
234
|
+
readonly name: string;
|
|
235
|
+
readonly models: DatabaseModels;
|
|
236
|
+
commit(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
237
|
+
dispose?: () => Promise<void>;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
export { AnalyticsModel, AnalyticsScanCursor, AnalyticsScanInput, ApiKeyModel, BundleModel, BundleModelQuery, BundlePatchModel, BundleRepository, BundleRepositoryChange, BundleRepositoryCommit, ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelModel, DatabaseChange, DatabaseCommit, DatabaseCommitExpectation, DatabaseCommitResult, DatabaseModels, DatabasePlugin, ReleaseCatalogModel, ReleaseModel };
|