@columnus/shared 0.1.56 → 0.1.59
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/apiProfile.d.ts +2 -0
- package/dist/apiProfile.js +2 -1
- package/dist/apiProfile.js.map +1 -1
- package/dist/assetGraph.d.ts +25 -3
- package/dist/assetGraph.js +30 -3
- package/dist/assetGraph.js.map +1 -1
- package/dist/assetJobs.d.ts +7 -3
- package/dist/assetJobs.js +2 -2
- package/dist/assetJobs.js.map +1 -1
- package/dist/assetSettings.d.ts +0 -6
- package/dist/assetSettings.js.map +1 -1
- package/dist/index.js +42 -64
- package/dist/index.js.map +1 -1
- package/dist/schemaGenerator.d.ts +0 -19
- package/dist/schemaGenerator.js +10 -60
- package/dist/schemaGenerator.js.map +1 -1
- package/dist/share.js.map +1 -1
- package/dist/shareApiBridge.js.map +1 -1
- package/dist/syncChannel.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { type Manifest } from "./schemaTypes.ts";
|
|
2
|
-
/**
|
|
3
|
-
* How `image`/`file` fields are validated in generated `schema.ts`.
|
|
4
|
-
*
|
|
5
|
-
* `storage-or-assets` is the G14 cutover window: Convex will not push a
|
|
6
|
-
* schema that existing documents fail, so the first deploy must still accept
|
|
7
|
-
* legacy `_storage` ids. After `migrateLegacyAssetFieldsPage` rewrites those
|
|
8
|
-
* values, the second deploy uses `assets`.
|
|
9
|
-
*/
|
|
10
|
-
export type AssetFieldIdContract = "assets" | "storage-or-assets";
|
|
11
2
|
export type GenerateSchemaOptions = {
|
|
12
3
|
includeColumnusTables?: boolean;
|
|
13
4
|
/** @deprecated Use includeColumnusTables */
|
|
@@ -20,14 +11,6 @@ export type GenerateSchemaOptions = {
|
|
|
20
11
|
includeAuditTable?: boolean;
|
|
21
12
|
/** When includeColumnusTables, omit columnus_display_values (owned by @columnus/component). Default true. */
|
|
22
13
|
includeDisplayValuesTable?: boolean;
|
|
23
|
-
/** Default `assets`. Use `storage-or-assets` only for the G14 first push. */
|
|
24
|
-
assetFieldIds?: AssetFieldIdContract;
|
|
25
|
-
/**
|
|
26
|
-
* Convex document validation on push. Default true. The G14 first push sets
|
|
27
|
-
* this false so existing `_storage` field values cannot block the kernel that
|
|
28
|
-
* contains the migrator.
|
|
29
|
-
*/
|
|
30
|
-
schemaValidation?: boolean;
|
|
31
14
|
};
|
|
32
15
|
/** User tables only — component tables live in @columnus/component. */
|
|
33
16
|
export declare const HOST_SCHEMA_PROFILE: {
|
|
@@ -51,5 +34,3 @@ export declare const ASSET_REFS_TABLE_NAME = "columnus_asset_refs";
|
|
|
51
34
|
export declare const ASSET_PROFILES_TABLE_NAME = "columnus_asset_profiles";
|
|
52
35
|
export declare const ASSET_SETTINGS_TABLE_NAME = "columnus_asset_settings";
|
|
53
36
|
export declare function generateSchemaTs(manifest: Manifest, opts?: GenerateSchemaOptions): string;
|
|
54
|
-
/** True when G14 must loosen `image`/`file` validators before rewriting `_storage` ids. */
|
|
55
|
-
export declare function manifestHasFileOrImageFields(manifest: Manifest): boolean;
|
package/dist/schemaGenerator.js
CHANGED
|
@@ -4591,9 +4591,8 @@ function generateSchemaTs(manifest, opts) {
|
|
|
4591
4591
|
const includeManifestTable = opts?.includeManifestTable ?? true;
|
|
4592
4592
|
const includeAuditTable = opts?.includeAuditTable ?? true;
|
|
4593
4593
|
const includeDisplayValuesTable = opts?.includeDisplayValuesTable ?? true;
|
|
4594
|
-
const assetFieldIds = opts?.assetFieldIds ?? "assets";
|
|
4595
4594
|
const userTables = [...manifest.tables].sort((a, b) => a.name.localeCompare(b.name));
|
|
4596
|
-
const userBody = userTables.map((t) => ` ${t.name}: ${renderTable(t
|
|
4595
|
+
const userBody = userTables.map((t) => ` ${t.name}: ${renderTable(t)},`).join("\n");
|
|
4597
4596
|
let body;
|
|
4598
4597
|
if (includeColumnusTables) {
|
|
4599
4598
|
const columnusSource = columnusTablesSource({
|
|
@@ -4609,15 +4608,14 @@ function generateSchemaTs(manifest, opts) {
|
|
|
4609
4608
|
const banner = includeColumnusTables ? BANNER : CONSUMER_BANNER;
|
|
4610
4609
|
const schemaBody = body ? `${body}
|
|
4611
4610
|
` : "";
|
|
4612
|
-
const schemaOpts = opts?.schemaValidation === false ? ", { schemaValidation: false }" : "";
|
|
4613
4611
|
return `${banner}import { defineSchema, defineTable } from "convex/server";
|
|
4614
4612
|
import { v } from "convex/values";
|
|
4615
4613
|
|
|
4616
4614
|
export default defineSchema({
|
|
4617
|
-
${schemaBody}}
|
|
4615
|
+
${schemaBody}});
|
|
4618
4616
|
`;
|
|
4619
4617
|
}
|
|
4620
|
-
function renderTable(t
|
|
4618
|
+
function renderTable(t) {
|
|
4621
4619
|
const fields = isAssetTable(t) ? [
|
|
4622
4620
|
...t.fields,
|
|
4623
4621
|
{
|
|
@@ -4628,7 +4626,7 @@ function renderTable(t, assetFieldIds) {
|
|
|
4628
4626
|
] : t.fields;
|
|
4629
4627
|
const fieldsBlock = fields.length ? `{
|
|
4630
4628
|
${fields.map((f) => {
|
|
4631
|
-
const inner = renderType(f.type
|
|
4629
|
+
const inner = renderType(f.type);
|
|
4632
4630
|
const value = f.optional ? `v.optional(${inner})` : inner;
|
|
4633
4631
|
return ` ${f.name}: ${value},`;
|
|
4634
4632
|
}).join("\n")}
|
|
@@ -4652,20 +4650,7 @@ ${fields.map((f) => {
|
|
|
4652
4650
|
}
|
|
4653
4651
|
return out;
|
|
4654
4652
|
}
|
|
4655
|
-
function
|
|
4656
|
-
const assetId = `v.id(${JSON.stringify(ASSETS_TABLE_NAME)})`;
|
|
4657
|
-
switch (assetFieldIds) {
|
|
4658
|
-
case "storage-or-assets":
|
|
4659
|
-
return `v.union(v.id("_storage"), ${assetId})`;
|
|
4660
|
-
case "assets":
|
|
4661
|
-
return assetId;
|
|
4662
|
-
default: {
|
|
4663
|
-
const _exhaustive = assetFieldIds;
|
|
4664
|
-
return _exhaustive;
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
|
-
function renderType(t, assetFieldIds) {
|
|
4653
|
+
function renderType(t) {
|
|
4669
4654
|
switch (t.kind) {
|
|
4670
4655
|
case "string":
|
|
4671
4656
|
case "markdown":
|
|
@@ -4687,63 +4672,28 @@ function renderType(t, assetFieldIds) {
|
|
|
4687
4672
|
return "v.bytes()";
|
|
4688
4673
|
case "file":
|
|
4689
4674
|
case "image":
|
|
4690
|
-
return
|
|
4675
|
+
return `v.id(${JSON.stringify(ASSETS_TABLE_NAME)})`;
|
|
4691
4676
|
case "id":
|
|
4692
4677
|
return `v.id(${JSON.stringify(t.table)})`;
|
|
4693
4678
|
case "literal":
|
|
4694
4679
|
return `v.literal(${JSON.stringify(t.value)})`;
|
|
4695
4680
|
case "array":
|
|
4696
|
-
return `v.array(${renderType(t.element
|
|
4681
|
+
return `v.array(${renderType(t.element)})`;
|
|
4697
4682
|
case "object": {
|
|
4698
4683
|
if (t.fields.length === 0) return `v.object({})`;
|
|
4699
4684
|
const inner = t.fields.map((f) => {
|
|
4700
|
-
const inner2 = renderType(f.type
|
|
4685
|
+
const inner2 = renderType(f.type);
|
|
4701
4686
|
const value = f.optional ? `v.optional(${inner2})` : inner2;
|
|
4702
4687
|
return `${f.name}: ${value}`;
|
|
4703
4688
|
}).join(", ");
|
|
4704
4689
|
return `v.object({ ${inner} })`;
|
|
4705
4690
|
}
|
|
4706
4691
|
case "union":
|
|
4707
|
-
return `v.union(${t.options.map((option) => renderType(option
|
|
4692
|
+
return `v.union(${t.options.map((option) => renderType(option)).join(", ")})`;
|
|
4708
4693
|
}
|
|
4709
4694
|
throw new Error(`unknown field kind: ${t.kind}`);
|
|
4710
4695
|
}
|
|
4711
|
-
function fieldTypeContainsFileOrImage(t) {
|
|
4712
|
-
switch (t.kind) {
|
|
4713
|
-
case "file":
|
|
4714
|
-
case "image":
|
|
4715
|
-
return true;
|
|
4716
|
-
case "array":
|
|
4717
|
-
return fieldTypeContainsFileOrImage(t.element);
|
|
4718
|
-
case "object":
|
|
4719
|
-
return t.fields.some((field) => fieldTypeContainsFileOrImage(field.type));
|
|
4720
|
-
case "union":
|
|
4721
|
-
return t.options.some(fieldTypeContainsFileOrImage);
|
|
4722
|
-
case "string":
|
|
4723
|
-
case "markdown":
|
|
4724
|
-
case "number":
|
|
4725
|
-
case "boolean":
|
|
4726
|
-
case "bigint":
|
|
4727
|
-
case "null":
|
|
4728
|
-
case "any":
|
|
4729
|
-
case "bytes":
|
|
4730
|
-
case "date":
|
|
4731
|
-
case "datetime":
|
|
4732
|
-
case "id":
|
|
4733
|
-
case "literal":
|
|
4734
|
-
return false;
|
|
4735
|
-
default: {
|
|
4736
|
-
const _exhaustive = t;
|
|
4737
|
-
return _exhaustive;
|
|
4738
|
-
}
|
|
4739
|
-
}
|
|
4740
|
-
}
|
|
4741
|
-
function manifestHasFileOrImageFields(manifest) {
|
|
4742
|
-
return manifest.tables.some(
|
|
4743
|
-
(table) => table.fields.some((field) => fieldTypeContainsFileOrImage(field.type))
|
|
4744
|
-
);
|
|
4745
|
-
}
|
|
4746
4696
|
|
|
4747
|
-
export { API_DELIVERY_TABLE_NAME, API_OUTBOX_TABLE_NAME, API_OUTPUTS_TABLE_NAME, API_OUTPUT_SECRETS_TABLE_NAME, API_PROFILES_TABLE_NAME, API_SYNC_ROUTES_TABLE_NAME, API_TOKENS_TABLE_NAME, ASSETS_TABLE_NAME, ASSET_PROFILES_TABLE_NAME, ASSET_REFS_TABLE_NAME, ASSET_SETTINGS_TABLE_NAME, ASSET_VERSIONS_TABLE_NAME, AUDIT_TABLE_NAME, DISPLAY_VALUES_TABLE_NAME, HOST_SCHEMA_PROFILE, INCOMING_REFS_TABLE_NAME, MANIFEST_TABLE_NAME, SPACES_TABLE_NAME, generateSchemaTs
|
|
4697
|
+
export { API_DELIVERY_TABLE_NAME, API_OUTBOX_TABLE_NAME, API_OUTPUTS_TABLE_NAME, API_OUTPUT_SECRETS_TABLE_NAME, API_PROFILES_TABLE_NAME, API_SYNC_ROUTES_TABLE_NAME, API_TOKENS_TABLE_NAME, ASSETS_TABLE_NAME, ASSET_PROFILES_TABLE_NAME, ASSET_REFS_TABLE_NAME, ASSET_SETTINGS_TABLE_NAME, ASSET_VERSIONS_TABLE_NAME, AUDIT_TABLE_NAME, DISPLAY_VALUES_TABLE_NAME, HOST_SCHEMA_PROFILE, INCOMING_REFS_TABLE_NAME, MANIFEST_TABLE_NAME, SPACES_TABLE_NAME, generateSchemaTs };
|
|
4748
4698
|
//# sourceMappingURL=schemaGenerator.js.map
|
|
4749
4699
|
//# sourceMappingURL=schemaGenerator.js.map
|