@instantdb/platform 0.22.94 → 0.22.95-experimental.surgical.20385805945.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.
@@ -1,35 +1,35 @@
1
1
 
2
- > @instantdb/platform@0.22.94 build /home/runner/work/instant/instant/client/packages/platform
2
+ > @instantdb/platform@0.22.95-experimental.surgical.20385805945.1 build /home/runner/work/instant/instant/client/packages/platform
3
3
  > rm -rf dist; npm run build:tshy && npm run build:standalone && npm run check-exports
4
4
 
5
5
  npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
6
6
  npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
7
7
 
8
- > @instantdb/platform@0.22.94 build:tshy
8
+ > @instantdb/platform@0.22.95-experimental.surgical.20385805945.1 build:tshy
9
9
  > tshy
10
10
 
11
11
  npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
12
12
  npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
13
13
 
14
- > @instantdb/platform@0.22.94 build:standalone
14
+ > @instantdb/platform@0.22.95-experimental.surgical.20385805945.1 build:standalone
15
15
  > vite build
16
16
 
17
17
  vite v5.4.14 building for production...
18
18
  transforming...
19
- ✓ 78 modules transformed.
19
+ ✓ 79 modules transformed.
20
20
  rendering chunks...
21
21
  computing gzip size...
22
- dist/standalone/index.umd.cjs 350.68 kB │ gzip: 95.22 kB
23
- dist/standalone/index.js 457.04 kB │ gzip: 107.08 kB
24
- ✓ built in 2.15s
22
+ dist/standalone/index.umd.cjs 352.64 kB │ gzip: 95.88 kB
23
+ dist/standalone/index.js 459.61 kB │ gzip: 107.84 kB
24
+ ✓ built in 2.31s
25
25
  npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm.
26
26
  npm warn Unknown user config "always-auth". This will stop working in the next major version of npm.
27
27
 
28
- > @instantdb/platform@0.22.94 check-exports
28
+ > @instantdb/platform@0.22.95-experimental.surgical.20385805945.1 check-exports
29
29
  > attw --pack .
30
30
 
31
31
 
32
- @instantdb/platform v0.22.94
32
+ @instantdb/platform v0.22.95-experimental.surgical.20385805945.1
33
33
 
34
34
  Build tools:
35
35
  - @arethetypeswrong/cli@^0.17.4
@@ -10,4 +10,5 @@ import { i, type InstantRules } from '@instantdb/core';
10
10
  import { exchangeCodeForToken, exchangeRefreshToken } from './serverOAuth.ts';
11
11
  export { type InstantAPIPlatformSchema, type InstantDBOAuthAccessToken, type OAuthHandlerConfig, type OAuthScope, type InstantRules, OAuthHandler, InstantOAuthError, generateSchemaTypescriptFile, validateSchema, SchemaValidationError, generatePermsTypescriptFile, apiSchemaToInstantSchemaDef, schemaTypescriptFileToInstantSchema, version, translatePlanSteps, PlatformApi, ProgressPromise, exchangeCodeForToken, exchangeRefreshToken, i, };
12
12
  export { diffSchemas, convertTxSteps, isRenamePromptItem, type RenameResolveFn, type MigrationTx, type MigrationTxSpecific, type MigrationTxTypes, type Identifier, } from './migrations.ts';
13
+ export { formatKey, renderAttrCall, renderAttrProperty, renderEntityProperty, renderLinkValue, renderLinkProperty, renderLinksObject, } from './schemaCodegen.ts';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,YAAY,EACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,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OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,YAAY,EACZ,iBAAiB,EACjB,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,mCAAmC,EACnC,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,CAAC,GACF,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isRenamePromptItem = exports.convertTxSteps = exports.diffSchemas = exports.i = exports.exchangeRefreshToken = exports.exchangeCodeForToken = exports.ProgressPromise = exports.PlatformApi = exports.translatePlanSteps = exports.version = exports.schemaTypescriptFileToInstantSchema = exports.apiSchemaToInstantSchemaDef = exports.generatePermsTypescriptFile = exports.SchemaValidationError = exports.validateSchema = exports.generateSchemaTypescriptFile = exports.InstantOAuthError = exports.OAuthHandler = void 0;
6
+ exports.renderLinksObject = exports.renderLinkProperty = exports.renderLinkValue = exports.renderEntityProperty = exports.renderAttrProperty = exports.renderAttrCall = exports.formatKey = exports.isRenamePromptItem = exports.convertTxSteps = exports.diffSchemas = exports.i = exports.exchangeRefreshToken = exports.exchangeCodeForToken = exports.ProgressPromise = exports.PlatformApi = exports.translatePlanSteps = exports.version = exports.schemaTypescriptFileToInstantSchema = exports.apiSchemaToInstantSchemaDef = exports.generatePermsTypescriptFile = exports.SchemaValidationError = exports.validateSchema = exports.generateSchemaTypescriptFile = exports.InstantOAuthError = exports.OAuthHandler = void 0;
7
7
  const oauthCommon_ts_1 = require("./oauthCommon.js");
8
8
  Object.defineProperty(exports, "InstantOAuthError", { enumerable: true, get: function () { return oauthCommon_ts_1.InstantOAuthError; } });
9
9
  const oauth_ts_1 = require("./oauth.js");
@@ -33,4 +33,12 @@ var migrations_ts_1 = require("./migrations.js");
33
33
  Object.defineProperty(exports, "diffSchemas", { enumerable: true, get: function () { return migrations_ts_1.diffSchemas; } });
34
34
  Object.defineProperty(exports, "convertTxSteps", { enumerable: true, get: function () { return migrations_ts_1.convertTxSteps; } });
35
35
  Object.defineProperty(exports, "isRenamePromptItem", { enumerable: true, get: function () { return migrations_ts_1.isRenamePromptItem; } });
36
+ var schemaCodegen_ts_1 = require("./schemaCodegen.js");
37
+ Object.defineProperty(exports, "formatKey", { enumerable: true, get: function () { return schemaCodegen_ts_1.formatKey; } });
38
+ Object.defineProperty(exports, "renderAttrCall", { enumerable: true, get: function () { return schemaCodegen_ts_1.renderAttrCall; } });
39
+ Object.defineProperty(exports, "renderAttrProperty", { enumerable: true, get: function () { return schemaCodegen_ts_1.renderAttrProperty; } });
40
+ Object.defineProperty(exports, "renderEntityProperty", { enumerable: true, get: function () { return schemaCodegen_ts_1.renderEntityProperty; } });
41
+ Object.defineProperty(exports, "renderLinkValue", { enumerable: true, get: function () { return schemaCodegen_ts_1.renderLinkValue; } });
42
+ Object.defineProperty(exports, "renderLinkProperty", { enumerable: true, get: function () { return schemaCodegen_ts_1.renderLinkProperty; } });
43
+ Object.defineProperty(exports, "renderLinksObject", { enumerable: true, get: function () { return schemaCodegen_ts_1.renderLinksObject; } });
36
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAsE;AAgCpE,kGAhCO,kCAAiB,OAgCP;AA/BnB,yCAIoB;AA0BlB,6FA3BA,uBAAY,OA2BA;AAzBd,yCAAyD;AA8BvD,4GA9BO,sCAA2B,OA8BP;AA7B7B,2CAKqB;AAqBnB,6GAxBA,wCAA4B,OAwBA;AAC5B,+FAxBA,0BAAc,OAwBA;AACd,sGAxBA,iCAAqB,OAwBA;AAtBvB,qCAIkB;AAoBhB,4GAvBA,oCAA2B,OAuBA;AAI3B,4FA1BA,oBAAW,OA0BA;AADX,mGAxBA,2BAAkB,OAwBA;AAtBpB,iEAA6E;AAoB3E,oHApBO,0DAAmC,OAoBP;AAlBrC,8DAAmC;AAmBjC,kBAnBK,oBAAO,CAmBL;AAlBT,6DAAuD;AAqBrD,gGArBO,oCAAe,OAqBP;AApBjB,0CAAuD;AAuBrD,kFAvBO,QAAC,OAuBP;AAtBH,qDAA8E;AAoB5E,qGApBO,qCAAoB,OAoBP;AACpB,qGArB6B,qCAAoB,OAqB7B;AAItB,iDASyB;AARvB,4GAAA,WAAW,OAAA;AACX,+GAAA,cAAc,OAAA;AACd,mHAAA,kBAAkB,OAAA","sourcesContent":["import { InstantOAuthError, type OAuthScope } from './oauthCommon.ts';\nimport {\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n OAuthHandler,\n} from './oauth.ts';\nimport { generatePermsTypescriptFile } from './perms.ts';\nimport {\n type InstantAPIPlatformSchema,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n} from './schema.ts';\nimport {\n apiSchemaToInstantSchemaDef,\n PlatformApi,\n translatePlanSteps,\n} from './api.ts';\nimport { schemaTypescriptFileToInstantSchema } from './typescript-schema.ts';\n\nimport version from './version.ts';\nimport { ProgressPromise } from './ProgressPromise.ts';\nimport { i, type InstantRules } from '@instantdb/core';\nimport { exchangeCodeForToken, exchangeRefreshToken } from './serverOAuth.ts';\n\nexport {\n type InstantAPIPlatformSchema,\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n type OAuthScope,\n type InstantRules,\n OAuthHandler,\n InstantOAuthError,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n generatePermsTypescriptFile,\n apiSchemaToInstantSchemaDef,\n schemaTypescriptFileToInstantSchema,\n version,\n translatePlanSteps,\n PlatformApi,\n ProgressPromise,\n exchangeCodeForToken,\n exchangeRefreshToken,\n i,\n};\n\nexport {\n diffSchemas,\n convertTxSteps,\n isRenamePromptItem,\n type RenameResolveFn,\n type MigrationTx,\n type MigrationTxSpecific,\n type MigrationTxTypes,\n type Identifier,\n} from './migrations.ts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAsE;AAgCpE,kGAhCO,kCAAiB,OAgCP;AA/BnB,yCAIoB;AA0BlB,6FA3BA,uBAAY,OA2BA;AAzBd,yCAAyD;AA8BvD,4GA9BO,sCAA2B,OA8BP;AA7B7B,2CAKqB;AAqBnB,6GAxBA,wCAA4B,OAwBA;AAC5B,+FAxBA,0BAAc,OAwBA;AACd,sGAxBA,iCAAqB,OAwBA;AAtBvB,qCAIkB;AAoBhB,4GAvBA,oCAA2B,OAuBA;AAI3B,4FA1BA,oBAAW,OA0BA;AADX,mGAxBA,2BAAkB,OAwBA;AAtBpB,iEAA6E;AAoB3E,oHApBO,0DAAmC,OAoBP;AAlBrC,8DAAmC;AAmBjC,kBAnBK,oBAAO,CAmBL;AAlBT,6DAAuD;AAqBrD,gGArBO,oCAAe,OAqBP;AApBjB,0CAAuD;AAuBrD,kFAvBO,QAAC,OAuBP;AAtBH,qDAA8E;AAoB5E,qGApBO,qCAAoB,OAoBP;AACpB,qGArB6B,qCAAoB,OAqB7B;AAItB,iDASyB;AARvB,4GAAA,WAAW,OAAA;AACX,+GAAA,cAAc,OAAA;AACd,mHAAA,kBAAkB,OAAA;AAQpB,uDAQ4B;AAP1B,6GAAA,SAAS,OAAA;AACT,kHAAA,cAAc,OAAA;AACd,sHAAA,kBAAkB,OAAA;AAClB,wHAAA,oBAAoB,OAAA;AACpB,mHAAA,eAAe,OAAA;AACf,sHAAA,kBAAkB,OAAA;AAClB,qHAAA,iBAAiB,OAAA","sourcesContent":["import { InstantOAuthError, type OAuthScope } from './oauthCommon.ts';\nimport {\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n OAuthHandler,\n} from './oauth.ts';\nimport { generatePermsTypescriptFile } from './perms.ts';\nimport {\n type InstantAPIPlatformSchema,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n} from './schema.ts';\nimport {\n apiSchemaToInstantSchemaDef,\n PlatformApi,\n translatePlanSteps,\n} from './api.ts';\nimport { schemaTypescriptFileToInstantSchema } from './typescript-schema.ts';\n\nimport version from './version.ts';\nimport { ProgressPromise } from './ProgressPromise.ts';\nimport { i, type InstantRules } from '@instantdb/core';\nimport { exchangeCodeForToken, exchangeRefreshToken } from './serverOAuth.ts';\n\nexport {\n type InstantAPIPlatformSchema,\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n type OAuthScope,\n type InstantRules,\n OAuthHandler,\n InstantOAuthError,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n generatePermsTypescriptFile,\n apiSchemaToInstantSchemaDef,\n schemaTypescriptFileToInstantSchema,\n version,\n translatePlanSteps,\n PlatformApi,\n ProgressPromise,\n exchangeCodeForToken,\n exchangeRefreshToken,\n i,\n};\n\nexport {\n diffSchemas,\n convertTxSteps,\n isRenamePromptItem,\n type RenameResolveFn,\n type MigrationTx,\n type MigrationTxSpecific,\n type MigrationTxTypes,\n type Identifier,\n} from './migrations.ts';\n\nexport {\n formatKey,\n renderAttrCall,\n renderAttrProperty,\n renderEntityProperty,\n renderLinkValue,\n renderLinkProperty,\n renderLinksObject,\n} from './schemaCodegen.ts';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,EACb,wBAAwB,EACxB,cAAc,EAIf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAKL,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,UAAU,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,aAAa,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,aAAa,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,cAAc,CAAC;IACrB,mBAA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;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,cAAc,GACzB,QAAQ,gBAAgB,EACxB,yBAAyB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,SA8DrD,CAAC"}
@@ -12,18 +12,12 @@ exports.attrFwdName = attrFwdName;
12
12
  exports.attrRevName = attrRevName;
13
13
  exports.generateSchemaTypescriptFile = generateSchemaTypescriptFile;
14
14
  const util_ts_1 = require("./util.js");
15
- function attrDefToCodeString([name, attr]) {
16
- var _a;
17
- const type = ((_a = attr.metadata.derivedType) === null || _a === void 0 ? void 0 : _a.type) || attr.valueType || 'any';
18
- const unique = attr.config.unique ? '.unique()' : '';
19
- const index = attr.config.indexed ? '.indexed()' : '';
20
- const required = attr.required ? '' : '.optional()';
21
- return `${(0, util_ts_1.formatKey)(name)}: i.${type}()${unique}${index}${required}`;
22
- }
15
+ const schemaCodegen_ts_1 = require("./schemaCodegen.js");
23
16
  function entityDefToCodeStr(name, edef) {
24
- const attrBlock = (0, util_ts_1.joinWithTrailingSep)((0, util_ts_1.sortedEntries)(edef.attrs).map(attrDefToCodeString), ',\n', ',');
25
- // a block of code for each entity
26
- return `${(0, util_ts_1.formatKey)(name)}: i.entity({${attrBlock.length ? '\n' : ''}${(0, util_ts_1.indentLines)(attrBlock, 2)}${attrBlock.length ? '\n' : ''}})`;
17
+ return (0, schemaCodegen_ts_1.renderEntityProperty)(name, edef.attrs, {
18
+ keyOptions: { alwaysQuote: true, quote: '"' },
19
+ trailingComma: true,
20
+ });
27
21
  }
28
22
  function identEtype(ident) {
29
23
  return ident[1];
@@ -67,7 +61,7 @@ function roomDefToCodeStr(room) {
67
61
  ret += `\n${(0, util_ts_1.indentLines)(entityDefToCodeStr('presence', room.presence), 4)},`;
68
62
  }
69
63
  if (room.topics) {
70
- ret += `\n "topics": {`;
64
+ ret += `\n ${(0, schemaCodegen_ts_1.formatKey)('topics', { alwaysQuote: true, quote: '"' })}: {`;
71
65
  for (const [topicName, topicConfig] of Object.entries(room.topics)) {
72
66
  ret += `\n${(0, util_ts_1.indentLines)(entityDefToCodeStr(topicName, topicConfig), 6)},`;
73
67
  }
@@ -79,7 +73,7 @@ function roomDefToCodeStr(room) {
79
73
  function roomsCodeStr(rooms) {
80
74
  let ret = '{';
81
75
  for (const [roomType, roomDef] of Object.entries(rooms)) {
82
- ret += `\n ${(0, util_ts_1.formatKey)(roomType)}: ${roomDefToCodeStr(roomDef)},`;
76
+ ret += `\n ${(0, schemaCodegen_ts_1.formatKey)(roomType, { alwaysQuote: true, quote: '"' })}: ${roomDefToCodeStr(roomDef)},`;
83
77
  }
84
78
  ret += ret === '{' ? '}' : '\n}';
85
79
  return ret;
@@ -102,7 +96,11 @@ function generateSchemaTypescriptFile(prevSchema, newSchema, instantModuleName)
102
96
  // Take a look at this schema, and if everything looks good,
103
97
  // run \`push schema\` again to enforce the types.`
104
98
  : '';
105
- const linksEntriesCode = JSON.stringify(newSchema.links, null, 2).trim();
99
+ const linksEntriesCode = (0, schemaCodegen_ts_1.renderLinksObject)(newSchema.links, {
100
+ keyOptions: { alwaysQuote: true, quote: '"' },
101
+ stringQuote: '"',
102
+ style: 'json',
103
+ });
106
104
  // rooms
107
105
  const rooms = (prevSchema === null || prevSchema === void 0 ? void 0 : prevSchema.rooms) || {};
108
106
  const roomsCode = roomsCodeStr(rooms);
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";;;AAkSA,gCAEC;AAED,gCAEC;AAED,8BAEC;AAED,oCAEC;AAED,oCAEC;AAED,oCAEC;AAED,oCAEC;AAED,kCAEC;AAED,kCAIC;AAsCD,oEA+DC;AA9ZD,uCAMmB;AAiPnB,SAAS,mBAAmB,CAAC,CAAC,IAAI,EAAE,IAAI,CAGvC;;IACC,MAAM,IAAI,GACR,CAAA,MAAC,IAAI,CAAC,QAAQ,CAAC,WAAmB,0CAAE,IAAI,KAAI,IAAI,CAAC,S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B,CAC7B,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,2CAA2C,CAC9H,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACzG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,qBAAqB,CAC7B,GAAG,WAAW,qCAAqC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CACvE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,qBAAqB,CAC7B,GAAG,WAAW,qCAAqC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CACvE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAhEW,QAAA,cAAc,kBAgEzB","sourcesContent":["import {\n AttrsDefs,\n CardinalityKind,\n DataAttrDef,\n EntityDef,\n InstantDBAttr,\n InstantDBCheckedDataType,\n InstantDBIdent,\n InstantSchemaDef,\n LinkAttrDef,\n RoomsDef,\n} from '@instantdb/core';\n\nimport {\n indentLines,\n joinWithTrailingSep,\n sortedEntries,\n formatKey,\n GenericSchemaDef,\n} from './util.ts';\n\nexport type InstantAPIPlatformSchema = {\n refs: Record<string, InstantDBAttr>;\n blobs: Record<string, Record<string, InstantDBAttr>>;\n};\n\nexport type InstantAPISchemaPlanAddAttrStep = {\n type: 'add-attr';\n friendlyDescription: string;\n attr: InstantDBAttr;\n};\n\nexport type InstantAPISchemaPlanDeleteAttrStep = {\n type: 'delete-attr';\n friendlyDescription: string;\n attrId: string;\n};\n\nexport type InstantAPISchemaPlanUpdateAttrStep = {\n type: 'update-attr';\n friendlyDescription: string;\n attr: InstantDBAttr;\n};\n\nexport type InstantAPISchemaPlanIndexStep = {\n type: 'index';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRemoveIndexStep = {\n type: 'remove-index';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanUniqueStep = {\n type: 'unique';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRemoveUniqueStep = {\n type: 'remove-unique';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRequiredStep = {\n type: 'required';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRemoveRequiredStep = {\n type: 'remove-required';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanCheckDataTypeStep = {\n type: 'check-data-type';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n checkedDataType: InstantDBCheckedDataType;\n};\n\nexport type InstantAPISchemaPlanRemoveDataTypeStep = {\n type: 'remove-data-type';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\ntype InstantBackgroundSchemaBaseJob = {\n id: string;\n createdAt: Date;\n updatedAt: Date;\n status: 'completed' | 'waiting' | 'processing' | 'errored';\n workEstimate: number | null;\n workCompleted: number | null;\n error?:\n | 'invalid-triple-error'\n | 'invalid-attr-state-error'\n | 'triple-not-unique-error'\n | 'triple-too-large-error'\n | 'missing-required-error'\n | 'unexpected-error';\n invalidTriplesSample?: {\n entityId: string;\n value: any;\n jsonType:\n | 'string'\n | 'number'\n | 'boolean'\n | 'null'\n | 'object'\n | 'array'\n | 'date';\n }[];\n};\n\ntype InstantBackgroundSchemaBaseJobWithInvalidTriples =\n InstantBackgroundSchemaBaseJob & {\n invalidTriplesSample?: {\n entityId: string;\n value: any;\n jsonType:\n | 'string'\n | 'number'\n | 'boolean'\n | 'null'\n | 'object'\n | 'array'\n | 'date';\n }[];\n };\n\nexport interface InstantBackgroundSchemaRemoveDataTypeJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-data-type';\n}\n\nexport interface InstantBackgroundSchemaCheckDataTypeJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'check-data-type';\n checkedDataType: InstantDBCheckedDataType;\n}\n\nexport interface InstantBackgroundSchemaAddIndexJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'index';\n}\n\nexport interface InstantBackgroundSchemaRemoveIndexJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-index';\n}\n\nexport interface InstantBackgroundSchemaAddUniqueJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'unique';\n invalidUniqueValue?: any;\n}\n\nexport interface InstantBackgroundSchemaRemoveUniqueJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-unique';\n}\n\nexport interface InstantBackgroundSchemaAddRequiredJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'required';\n}\n\nexport interface InstantBackgroundSchemaRemoveRequiredJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-required';\n}\n\nexport type InstantAPISchemaPlanStep =\n | InstantAPISchemaPlanAddAttrStep\n | InstantAPISchemaPlanDeleteAttrStep\n | InstantAPISchemaPlanUpdateAttrStep\n | InstantAPISchemaPlanIndexStep\n | InstantAPISchemaPlanRemoveIndexStep\n | InstantAPISchemaPlanUniqueStep\n | InstantAPISchemaPlanRemoveUniqueStep\n | InstantAPISchemaPlanRequiredStep\n | InstantAPISchemaPlanRemoveRequiredStep\n | InstantAPISchemaPlanCheckDataTypeStep\n | InstantAPISchemaPlanRemoveDataTypeStep;\n\ntype BackgroundJobByStep = {\n index: InstantBackgroundSchemaAddIndexJob;\n 'remove-index': InstantBackgroundSchemaRemoveIndexJob;\n unique: InstantBackgroundSchemaAddUniqueJob;\n 'remove-unique': InstantBackgroundSchemaRemoveUniqueJob;\n required: InstantBackgroundSchemaAddRequiredJob;\n 'remove-required': InstantBackgroundSchemaRemoveRequiredJob;\n 'check-data-type': InstantBackgroundSchemaCheckDataTypeJob;\n 'remove-data-type': InstantBackgroundSchemaRemoveDataTypeJob;\n};\n\n// Adds the proper flavor of the backgroundJob type to the steps\n// that run in the background\nexport type WithBackgroundJob<P extends { type: string }> =\n P['type'] extends keyof BackgroundJobByStep\n ? P & { backgroundJob: BackgroundJobByStep[P['type']] }\n : P;\n\nexport type InstantAPISchemaPushAddAttrStep =\n WithBackgroundJob<InstantAPISchemaPlanAddAttrStep>;\n\nexport type InstantAPISchemaPushUpdateAttrStep =\n WithBackgroundJob<InstantAPISchemaPlanUpdateAttrStep>;\n\nexport type InstantAPISchemaPushIndexStep =\n WithBackgroundJob<InstantAPISchemaPlanIndexStep>;\n\nexport type InstantAPISchemaPushRemoveIndexStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveIndexStep>;\n\nexport type InstantAPISchemaPushUniqueStep =\n WithBackgroundJob<InstantAPISchemaPlanUniqueStep>;\n\nexport type InstantAPISchemaPushRemoveUniqueStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveUniqueStep>;\n\nexport type InstantAPISchemaPushRequiredStep =\n WithBackgroundJob<InstantAPISchemaPlanRequiredStep>;\n\nexport type InstantAPISchemaPushRemoveRequiredStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveRequiredStep>;\n\nexport type InstantAPISchemaPushCheckDataTypeStep =\n WithBackgroundJob<InstantAPISchemaPlanCheckDataTypeStep>;\n\nexport type InstantAPISchemaPushRemoveDataTypeStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveDataTypeStep>;\n\nexport type InstantAPISchemaPushStep =\n | InstantAPISchemaPushAddAttrStep\n | InstantAPISchemaPushUpdateAttrStep\n | InstantAPISchemaPushIndexStep\n | InstantAPISchemaPushRemoveIndexStep\n | InstantAPISchemaPushUniqueStep\n | InstantAPISchemaPushRemoveUniqueStep\n | InstantAPISchemaPushRequiredStep\n | InstantAPISchemaPushRemoveRequiredStep\n | InstantAPISchemaPushCheckDataTypeStep\n | InstantAPISchemaPushRemoveDataTypeStep;\n\nfunction attrDefToCodeString([name, attr]: [\n string,\n DataAttrDef<string, boolean, boolean>,\n]) {\n const type =\n (attr.metadata.derivedType as any)?.type || attr.valueType || 'any';\n const unique = attr.config.unique ? '.unique()' : '';\n const index = attr.config.indexed ? '.indexed()' : '';\n const required = attr.required ? '' : '.optional()';\n return `${formatKey(name)}: i.${type}()${unique}${index}${required}`;\n}\n\nfunction entityDefToCodeStr(\n name: string,\n edef: EntityDef<\n AttrsDefs,\n Record<string, LinkAttrDef<CardinalityKind, string>>,\n any\n >,\n) {\n const attrBlock = joinWithTrailingSep(\n sortedEntries(edef.attrs).map(attrDefToCodeString),\n ',\\n',\n ',',\n );\n\n // a block of code for each entity\n return `${formatKey(name)}: i.entity({${attrBlock.length ? '\\n' : ''}${indentLines(attrBlock, 2)}${attrBlock.length ? '\\n' : ''}})`;\n}\n\nexport function identEtype(ident: InstantDBIdent) {\n return ident[1];\n}\n\nexport function identLabel(ident: InstantDBIdent) {\n return ident[2];\n}\n\nexport function identName(ident: InstantDBIdent) {\n return `${identEtype(ident)}.${identLabel(ident)}`;\n}\n\nexport function attrFwdLabel(attr: InstantDBAttr) {\n return attr['forward-identity']?.[2];\n}\n\nexport function attrFwdEtype(attr: InstantDBAttr) {\n return attr['forward-identity']?.[1];\n}\n\nexport function attrRevLabel(attr: InstantDBAttr) {\n return attr['reverse-identity']?.[2];\n}\n\nexport function attrRevEtype(attr: InstantDBAttr) {\n return attr['reverse-identity']?.[1];\n}\n\nexport function attrFwdName(attr: InstantDBAttr) {\n return `${attrFwdEtype(attr)}.${attrFwdLabel(attr)}`;\n}\n\nexport function attrRevName(attr: InstantDBAttr) {\n if (attr['reverse-identity']) {\n return `${attrRevEtype(attr)}.${attrRevLabel(attr)}`;\n }\n}\n\nfunction easyPlural(strn: string, n: number) {\n return n === 1 ? strn : strn + 's';\n}\n\nfunction roomDefToCodeStr(room: RoomsDef[string]) {\n let ret = '{';\n\n if (room.presence) {\n ret += `\\n${indentLines(entityDefToCodeStr('presence', room.presence), 4)},`;\n }\n\n if (room.topics) {\n ret += `\\n \"topics\": {`;\n\n for (const [topicName, topicConfig] of Object.entries(room.topics)) {\n ret += `\\n${indentLines(entityDefToCodeStr(topicName, topicConfig), 6)},`;\n }\n ret += `\\n }`;\n }\n\n ret += ret === '{' ? '}' : '\\n }';\n\n return ret;\n}\n\nfunction roomsCodeStr(rooms: RoomsDef) {\n let ret = '{';\n\n for (const [roomType, roomDef] of Object.entries(rooms)) {\n ret += `\\n ${formatKey(roomType)}: ${roomDefToCodeStr(roomDef)},`;\n }\n ret += ret === '{' ? '}' : '\\n}';\n\n return ret;\n}\n\nexport function generateSchemaTypescriptFile(\n prevSchema: GenericSchemaDef | null | undefined,\n newSchema: GenericSchemaDef,\n instantModuleName: string,\n): string {\n // entities\n const entitiesEntriesCode = joinWithTrailingSep(\n sortedEntries(newSchema.entities).map(([etype, entityDef]) =>\n entityDefToCodeStr(etype, entityDef),\n ),\n ',\\n',\n ',',\n );\n\n const inferredAttrs: DataAttrDef<string, boolean, boolean>[] = [];\n\n for (const entity of Object.values(newSchema.entities)) {\n for (const attr of Object.values(entity.attrs)) {\n if ((attr.metadata.derivedType as any)?.origin === 'inferred') {\n inferredAttrs.push(attr);\n }\n }\n }\n\n const entitiesObjCode = `{\\n${indentLines(entitiesEntriesCode, 2)}\\n}`;\n\n const entitiesComment =\n inferredAttrs.length > 0\n ? `// We inferred ${inferredAttrs.length} ${easyPlural('attribute', inferredAttrs.length)}!\n// Take a look at this schema, and if everything looks good,\n// run \\`push schema\\` again to enforce the types.`\n : '';\n\n const linksEntriesCode = JSON.stringify(newSchema.links, null, 2).trim();\n\n // rooms\n const rooms = prevSchema?.rooms || {};\n const roomsCode = roomsCodeStr(rooms);\n const kv = (k: string, v: string, comment?: string) => {\n const res = comment ? `${comment}\\n${k}: ${v}` : `${k}: ${v}`;\n return indentLines(res, 2);\n };\n\n const code = `// Docs: https://www.instantdb.com/docs/modeling-data\n\nimport { i } from \"${instantModuleName ?? '@instantdb/core'}\";\n\nconst _schema = i.schema({\n${kv('entities', entitiesObjCode, entitiesComment)},\n${kv('links', linksEntriesCode)},\n${kv('rooms', roomsCode)}\n});\n\n// This helps Typescript display nicer intellisense\ntype _AppSchema = typeof _schema;\ninterface AppSchema extends _AppSchema {}\nconst schema: AppSchema = _schema;\n\nexport type { AppSchema }\nexport default schema;\n`;\n\n return code;\n}\n\nexport class SchemaValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SchemaValidationError';\n }\n}\n\nexport const validateSchema = (\n schema: GenericSchemaDef,\n systemCatalogIdentNames: Record<string, Set<string>>,\n) => {\n const entityNames = Object.keys(schema.entities);\n\n for (const [etype, entityDef] of Object.entries(schema.entities)) {\n if (!etype.startsWith('$')) continue;\n if (!systemCatalogIdentNames[etype]) {\n throw new SchemaValidationError(\n 'The $ keyword is reserved for system namespaces.' +\n `\\nYou can't create '${etype}'. Perhaps call it '${etype.slice(1)}' instead?`,\n );\n }\n for (const [attrName, attrDef] of Object.entries(entityDef.attrs)) {\n if (systemCatalogIdentNames[etype].has(attrName)) {\n continue;\n }\n if (attrDef.required) {\n throw new SchemaValidationError(\n `The '${etype}' namespace is managed by the system and can't modify required constraints yet.` +\n `\\nMake sure to set ${etype}.${attrName} as optional.` +\n `\\n i.e { ${attrName}: i.${attrDef.valueType}().optional() }`,\n );\n }\n }\n }\n\n for (const link of Object.values(schema.links)) {\n if (\n systemCatalogIdentNames[link.forward.on] &&\n !systemCatalogIdentNames[link.forward.on].has(link.forward.label) &&\n link.forward.required\n ) {\n throw new SchemaValidationError(\n `The ${link.forward.on} namespace is managed by the system and can't modify required constraints yet.` +\n `\\nMake sure to set ${link.forward.on}${link.forward.label} as 'optional'.` +\n `\\n i.e { 'on': '${link.forward.on}', 'label': ${link.forward.label}, 'required': false }`,\n );\n }\n\n if (link.forward.has === 'many' && link.forward.onDelete === 'cascade') {\n throw new SchemaValidationError(\n `${link.forward.on}${link.forward.label} -> ${link.reverse.on}${link.reverse.label} has onDelete: \"cascade\" with has: \"many\"`,\n );\n }\n if (link.reverse.has === 'many' && link.reverse.onDelete === 'cascade') {\n throw new SchemaValidationError(\n `${link.forward.on}${link.forward.label} -> ${link.reverse.on}${link.reverse.label} has onDelete: \"cascade\" with has: \"many\"`,\n );\n }\n\n const linkDisplay = `${link.forward.on}${link.forward.label} -> ${link.reverse.on}${link.reverse.label}`;\n if (!entityNames.includes(link.forward.on)) {\n throw new SchemaValidationError(\n `${linkDisplay} connects to non existing entity \"${link.forward.on}\".`,\n );\n }\n if (!entityNames.includes(link.reverse.on)) {\n throw new SchemaValidationError(\n `${linkDisplay} connects to non existing entity \"${link.forward.on}\".`,\n );\n }\n }\n};\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";;;AAsRA,gCAEC;AAED,gCAEC;AAED,8BAEC;AAED,oCAEC;AAED,oCAEC;AAED,oCAEC;AAED,oCAEC;AAED,kCAEC;AAED,kCAIC;AAsCD,oEAmEC;AAtZD,uCAKmB;AACnB,yDAI4B;AAiP5B,SAAS,kBAAkB,CACzB,IAAY,EACZ,IAIC;IAED,OAAO,IAAA,uCAAoB,EAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;QAC5C,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;QAC7C,aAAa,EAAE,IAAI;KACpB,CAA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IAAI,qBAAqB,CAC7B,GAAG,WAAW,qCAAqC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CACvE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAhEW,QAAA,cAAc,kBAgEzB","sourcesContent":["import {\n AttrsDefs,\n CardinalityKind,\n DataAttrDef,\n EntityDef,\n InstantDBAttr,\n InstantDBCheckedDataType,\n InstantDBIdent,\n InstantSchemaDef,\n LinkAttrDef,\n RoomsDef,\n} from '@instantdb/core';\n\nimport {\n indentLines,\n joinWithTrailingSep,\n sortedEntries,\n GenericSchemaDef,\n} from './util.ts';\nimport {\n formatKey,\n renderEntityProperty,\n renderLinksObject,\n} from './schemaCodegen.ts';\n\nexport type InstantAPIPlatformSchema = {\n refs: Record<string, InstantDBAttr>;\n blobs: Record<string, Record<string, InstantDBAttr>>;\n};\n\nexport type InstantAPISchemaPlanAddAttrStep = {\n type: 'add-attr';\n friendlyDescription: string;\n attr: InstantDBAttr;\n};\n\nexport type InstantAPISchemaPlanDeleteAttrStep = {\n type: 'delete-attr';\n friendlyDescription: string;\n attrId: string;\n};\n\nexport type InstantAPISchemaPlanUpdateAttrStep = {\n type: 'update-attr';\n friendlyDescription: string;\n attr: InstantDBAttr;\n};\n\nexport type InstantAPISchemaPlanIndexStep = {\n type: 'index';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRemoveIndexStep = {\n type: 'remove-index';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanUniqueStep = {\n type: 'unique';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRemoveUniqueStep = {\n type: 'remove-unique';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRequiredStep = {\n type: 'required';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanRemoveRequiredStep = {\n type: 'remove-required';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\nexport type InstantAPISchemaPlanCheckDataTypeStep = {\n type: 'check-data-type';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n checkedDataType: InstantDBCheckedDataType;\n};\n\nexport type InstantAPISchemaPlanRemoveDataTypeStep = {\n type: 'remove-data-type';\n friendlyDescription: string;\n attrId: string;\n forwardIdentity: InstantDBIdent;\n};\n\ntype InstantBackgroundSchemaBaseJob = {\n id: string;\n createdAt: Date;\n updatedAt: Date;\n status: 'completed' | 'waiting' | 'processing' | 'errored';\n workEstimate: number | null;\n workCompleted: number | null;\n error?:\n | 'invalid-triple-error'\n | 'invalid-attr-state-error'\n | 'triple-not-unique-error'\n | 'triple-too-large-error'\n | 'missing-required-error'\n | 'unexpected-error';\n invalidTriplesSample?: {\n entityId: string;\n value: any;\n jsonType:\n | 'string'\n | 'number'\n | 'boolean'\n | 'null'\n | 'object'\n | 'array'\n | 'date';\n }[];\n};\n\ntype InstantBackgroundSchemaBaseJobWithInvalidTriples =\n InstantBackgroundSchemaBaseJob & {\n invalidTriplesSample?: {\n entityId: string;\n value: any;\n jsonType:\n | 'string'\n | 'number'\n | 'boolean'\n | 'null'\n | 'object'\n | 'array'\n | 'date';\n }[];\n };\n\nexport interface InstantBackgroundSchemaRemoveDataTypeJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-data-type';\n}\n\nexport interface InstantBackgroundSchemaCheckDataTypeJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'check-data-type';\n checkedDataType: InstantDBCheckedDataType;\n}\n\nexport interface InstantBackgroundSchemaAddIndexJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'index';\n}\n\nexport interface InstantBackgroundSchemaRemoveIndexJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-index';\n}\n\nexport interface InstantBackgroundSchemaAddUniqueJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'unique';\n invalidUniqueValue?: any;\n}\n\nexport interface InstantBackgroundSchemaRemoveUniqueJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-unique';\n}\n\nexport interface InstantBackgroundSchemaAddRequiredJob\n extends InstantBackgroundSchemaBaseJobWithInvalidTriples {\n type: 'required';\n}\n\nexport interface InstantBackgroundSchemaRemoveRequiredJob\n extends InstantBackgroundSchemaBaseJob {\n type: 'remove-required';\n}\n\nexport type InstantAPISchemaPlanStep =\n | InstantAPISchemaPlanAddAttrStep\n | InstantAPISchemaPlanDeleteAttrStep\n | InstantAPISchemaPlanUpdateAttrStep\n | InstantAPISchemaPlanIndexStep\n | InstantAPISchemaPlanRemoveIndexStep\n | InstantAPISchemaPlanUniqueStep\n | InstantAPISchemaPlanRemoveUniqueStep\n | InstantAPISchemaPlanRequiredStep\n | InstantAPISchemaPlanRemoveRequiredStep\n | InstantAPISchemaPlanCheckDataTypeStep\n | InstantAPISchemaPlanRemoveDataTypeStep;\n\ntype BackgroundJobByStep = {\n index: InstantBackgroundSchemaAddIndexJob;\n 'remove-index': InstantBackgroundSchemaRemoveIndexJob;\n unique: InstantBackgroundSchemaAddUniqueJob;\n 'remove-unique': InstantBackgroundSchemaRemoveUniqueJob;\n required: InstantBackgroundSchemaAddRequiredJob;\n 'remove-required': InstantBackgroundSchemaRemoveRequiredJob;\n 'check-data-type': InstantBackgroundSchemaCheckDataTypeJob;\n 'remove-data-type': InstantBackgroundSchemaRemoveDataTypeJob;\n};\n\n// Adds the proper flavor of the backgroundJob type to the steps\n// that run in the background\nexport type WithBackgroundJob<P extends { type: string }> =\n P['type'] extends keyof BackgroundJobByStep\n ? P & { backgroundJob: BackgroundJobByStep[P['type']] }\n : P;\n\nexport type InstantAPISchemaPushAddAttrStep =\n WithBackgroundJob<InstantAPISchemaPlanAddAttrStep>;\n\nexport type InstantAPISchemaPushUpdateAttrStep =\n WithBackgroundJob<InstantAPISchemaPlanUpdateAttrStep>;\n\nexport type InstantAPISchemaPushIndexStep =\n WithBackgroundJob<InstantAPISchemaPlanIndexStep>;\n\nexport type InstantAPISchemaPushRemoveIndexStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveIndexStep>;\n\nexport type InstantAPISchemaPushUniqueStep =\n WithBackgroundJob<InstantAPISchemaPlanUniqueStep>;\n\nexport type InstantAPISchemaPushRemoveUniqueStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveUniqueStep>;\n\nexport type InstantAPISchemaPushRequiredStep =\n WithBackgroundJob<InstantAPISchemaPlanRequiredStep>;\n\nexport type InstantAPISchemaPushRemoveRequiredStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveRequiredStep>;\n\nexport type InstantAPISchemaPushCheckDataTypeStep =\n WithBackgroundJob<InstantAPISchemaPlanCheckDataTypeStep>;\n\nexport type InstantAPISchemaPushRemoveDataTypeStep =\n WithBackgroundJob<InstantAPISchemaPlanRemoveDataTypeStep>;\n\nexport type InstantAPISchemaPushStep =\n | InstantAPISchemaPushAddAttrStep\n | InstantAPISchemaPushUpdateAttrStep\n | InstantAPISchemaPushIndexStep\n | InstantAPISchemaPushRemoveIndexStep\n | InstantAPISchemaPushUniqueStep\n | InstantAPISchemaPushRemoveUniqueStep\n | InstantAPISchemaPushRequiredStep\n | InstantAPISchemaPushRemoveRequiredStep\n | InstantAPISchemaPushCheckDataTypeStep\n | InstantAPISchemaPushRemoveDataTypeStep;\n\nfunction entityDefToCodeStr(\n name: string,\n edef: EntityDef<\n AttrsDefs,\n Record<string, LinkAttrDef<CardinalityKind, string>>,\n any\n >,\n) {\n return renderEntityProperty(name, edef.attrs, {\n keyOptions: { alwaysQuote: true, quote: '\"' },\n trailingComma: true,\n });\n}\n\nexport function identEtype(ident: InstantDBIdent) {\n return ident[1];\n}\n\nexport function identLabel(ident: InstantDBIdent) {\n return ident[2];\n}\n\nexport function identName(ident: InstantDBIdent) {\n return `${identEtype(ident)}.${identLabel(ident)}`;\n}\n\nexport function attrFwdLabel(attr: InstantDBAttr) {\n return attr['forward-identity']?.[2];\n}\n\nexport function attrFwdEtype(attr: InstantDBAttr) {\n return attr['forward-identity']?.[1];\n}\n\nexport function attrRevLabel(attr: InstantDBAttr) {\n return attr['reverse-identity']?.[2];\n}\n\nexport function attrRevEtype(attr: InstantDBAttr) {\n return attr['reverse-identity']?.[1];\n}\n\nexport function attrFwdName(attr: InstantDBAttr) {\n return `${attrFwdEtype(attr)}.${attrFwdLabel(attr)}`;\n}\n\nexport function attrRevName(attr: InstantDBAttr) {\n if (attr['reverse-identity']) {\n return `${attrRevEtype(attr)}.${attrRevLabel(attr)}`;\n }\n}\n\nfunction easyPlural(strn: string, n: number) {\n return n === 1 ? strn : strn + 's';\n}\n\nfunction roomDefToCodeStr(room: RoomsDef[string]) {\n let ret = '{';\n\n if (room.presence) {\n ret += `\\n${indentLines(entityDefToCodeStr('presence', room.presence), 4)},`;\n }\n\n if (room.topics) {\n ret += `\\n ${formatKey('topics', { alwaysQuote: true, quote: '\"' })}: {`;\n\n for (const [topicName, topicConfig] of Object.entries(room.topics)) {\n ret += `\\n${indentLines(entityDefToCodeStr(topicName, topicConfig), 6)},`;\n }\n ret += `\\n }`;\n }\n\n ret += ret === '{' ? '}' : '\\n }';\n\n return ret;\n}\n\nfunction roomsCodeStr(rooms: RoomsDef) {\n let ret = '{';\n\n for (const [roomType, roomDef] of Object.entries(rooms)) {\n ret += `\\n ${formatKey(roomType, { alwaysQuote: true, quote: '\"' })}: ${roomDefToCodeStr(roomDef)},`;\n }\n ret += ret === '{' ? '}' : '\\n}';\n\n return ret;\n}\n\nexport function generateSchemaTypescriptFile(\n prevSchema: GenericSchemaDef | null | undefined,\n newSchema: GenericSchemaDef,\n instantModuleName: string,\n): string {\n // entities\n const entitiesEntriesCode = joinWithTrailingSep(\n sortedEntries(newSchema.entities).map(([etype, entityDef]) =>\n entityDefToCodeStr(etype, entityDef),\n ),\n ',\\n',\n ',',\n );\n\n const inferredAttrs: DataAttrDef<string, boolean, boolean>[] = [];\n\n for (const entity of Object.values(newSchema.entities)) {\n for (const attr of Object.values(entity.attrs)) {\n if ((attr.metadata.derivedType as any)?.origin === 'inferred') {\n inferredAttrs.push(attr);\n }\n }\n }\n\n const entitiesObjCode = `{\\n${indentLines(entitiesEntriesCode, 2)}\\n}`;\n\n const entitiesComment =\n inferredAttrs.length > 0\n ? `// We inferred ${inferredAttrs.length} ${easyPlural('attribute', inferredAttrs.length)}!\n// Take a look at this schema, and if everything looks good,\n// run \\`push schema\\` again to enforce the types.`\n : '';\n\n const linksEntriesCode = renderLinksObject(newSchema.links, {\n keyOptions: { alwaysQuote: true, quote: '\"' },\n stringQuote: '\"',\n style: 'json',\n });\n\n // rooms\n const rooms = prevSchema?.rooms || {};\n const roomsCode = roomsCodeStr(rooms);\n const kv = (k: string, v: string, comment?: string) => {\n const res = comment ? `${comment}\\n${k}: ${v}` : `${k}: ${v}`;\n return indentLines(res, 2);\n };\n\n const code = `// Docs: https://www.instantdb.com/docs/modeling-data\n\nimport { i } from \"${instantModuleName ?? '@instantdb/core'}\";\n\nconst _schema = i.schema({\n${kv('entities', entitiesObjCode, entitiesComment)},\n${kv('links', linksEntriesCode)},\n${kv('rooms', roomsCode)}\n});\n\n// This helps Typescript display nicer intellisense\ntype _AppSchema = typeof _schema;\ninterface AppSchema extends _AppSchema {}\nconst schema: AppSchema = _schema;\n\nexport type { AppSchema }\nexport default schema;\n`;\n\n return code;\n}\n\nexport class SchemaValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SchemaValidationError';\n }\n}\n\nexport const validateSchema = (\n schema: GenericSchemaDef,\n systemCatalogIdentNames: Record<string, Set<string>>,\n) => {\n const entityNames = Object.keys(schema.entities);\n\n for (const [etype, entityDef] of Object.entries(schema.entities)) {\n if (!etype.startsWith('$')) continue;\n if (!systemCatalogIdentNames[etype]) {\n throw new SchemaValidationError(\n 'The $ keyword is reserved for system namespaces.' +\n `\\nYou can't create '${etype}'. Perhaps call it '${etype.slice(1)}' instead?`,\n );\n }\n for (const [attrName, attrDef] of Object.entries(entityDef.attrs)) {\n if (systemCatalogIdentNames[etype].has(attrName)) {\n continue;\n }\n if (attrDef.required) {\n throw new SchemaValidationError(\n `The '${etype}' namespace is managed by the system and can't modify required constraints yet.` +\n `\\nMake sure to set ${etype}.${attrName} as optional.` +\n `\\n i.e { ${attrName}: i.${attrDef.valueType}().optional() }`,\n );\n }\n }\n }\n\n for (const link of Object.values(schema.links)) {\n if (\n systemCatalogIdentNames[link.forward.on] &&\n !systemCatalogIdentNames[link.forward.on].has(link.forward.label) &&\n link.forward.required\n ) {\n throw new SchemaValidationError(\n `The ${link.forward.on} namespace is managed by the system and can't modify required constraints yet.` +\n `\\nMake sure to set ${link.forward.on}${link.forward.label} as 'optional'.` +\n `\\n i.e { 'on': '${link.forward.on}', 'label': ${link.forward.label}, 'required': false }`,\n );\n }\n\n if (link.forward.has === 'many' && link.forward.onDelete === 'cascade') {\n throw new SchemaValidationError(\n `${link.forward.on}${link.forward.label} -> ${link.reverse.on}${link.reverse.label} has onDelete: \"cascade\" with has: \"many\"`,\n );\n }\n if (link.reverse.has === 'many' && link.reverse.onDelete === 'cascade') {\n throw new SchemaValidationError(\n `${link.forward.on}${link.forward.label} -> ${link.reverse.on}${link.reverse.label} has onDelete: \"cascade\" with has: \"many\"`,\n );\n }\n\n const linkDisplay = `${link.forward.on}${link.forward.label} -> ${link.reverse.on}${link.reverse.label}`;\n if (!entityNames.includes(link.forward.on)) {\n throw new SchemaValidationError(\n `${linkDisplay} connects to non existing entity \"${link.forward.on}\".`,\n );\n }\n if (!entityNames.includes(link.reverse.on)) {\n throw new SchemaValidationError(\n `${linkDisplay} connects to non existing entity \"${link.forward.on}\".`,\n );\n }\n }\n};\n"]}
@@ -0,0 +1,37 @@
1
+ import type { AttrsDefs, DataAttrDef, LinkDef, LinksDef } from '@instantdb/core';
2
+ type AnyLink = LinkDef<any, any, any, any, any, any, any>;
3
+ type KeyFormatOptions = {
4
+ alwaysQuote?: boolean;
5
+ quote?: '"' | "'";
6
+ };
7
+ type EntityRenderOptions = {
8
+ indent?: number;
9
+ typeParamsByAttr?: Record<string, string | null | undefined>;
10
+ keyOptions?: KeyFormatOptions;
11
+ trailingComma?: boolean;
12
+ };
13
+ type LinkRenderOptions = {
14
+ indent?: number;
15
+ keyOptions?: KeyFormatOptions;
16
+ stringQuote?: '"' | "'";
17
+ style?: 'js' | 'json';
18
+ };
19
+ type LinksObjectOptions = {
20
+ indent?: number;
21
+ newlineForEmpty?: boolean;
22
+ keyOptions?: KeyFormatOptions;
23
+ stringQuote?: '"' | "'";
24
+ style?: 'js' | 'json';
25
+ };
26
+ export declare function formatKey(name: string, options?: KeyFormatOptions): string;
27
+ export declare function renderAttrCall(attr: DataAttrDef<string, boolean, boolean>, typeParams?: string | null): string;
28
+ export declare function renderAttrProperty(name: string, attr: DataAttrDef<string, boolean, boolean>, options?: {
29
+ typeParams?: string | null;
30
+ keyOptions?: KeyFormatOptions;
31
+ }): string;
32
+ export declare function renderEntityProperty(name: string, attrs: AttrsDefs, options?: EntityRenderOptions): string;
33
+ export declare function renderLinkValue(link: AnyLink, options?: LinkRenderOptions): string;
34
+ export declare function renderLinkProperty(name: string, link: AnyLink, options?: LinkRenderOptions): string;
35
+ export declare function renderLinksObject(links: LinksDef<any>, options?: LinksObjectOptions): string;
36
+ export {};
37
+ //# sourceMappingURL=schemaCodegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaCodegen.d.ts","sourceRoot":"","sources":["../../src/schemaCodegen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKjF,KAAK,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,G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,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAAO,UAM5E;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,OAAO,GAAE,mBAAwB,UAuBlC;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,iBAAsB,UAuDhC;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,iBAAsB,UAMhC;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,EACpB,OAAO,GAAE,kBAAuB,UAgBjC"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatKey = formatKey;
4
+ exports.renderAttrCall = renderAttrCall;
5
+ exports.renderAttrProperty = renderAttrProperty;
6
+ exports.renderEntityProperty = renderEntityProperty;
7
+ exports.renderLinkValue = renderLinkValue;
8
+ exports.renderLinkProperty = renderLinkProperty;
9
+ exports.renderLinksObject = renderLinksObject;
10
+ const util_ts_1 = require("./util.js");
11
+ const DEFAULT_INDENT = 2;
12
+ function formatKey(name, options = {}) {
13
+ var _a;
14
+ const quote = (_a = options.quote) !== null && _a !== void 0 ? _a : "'";
15
+ if (!options.alwaysQuote && isValidIdentifier(name)) {
16
+ return name;
17
+ }
18
+ return `${quote}${name}${quote}`;
19
+ }
20
+ function renderAttrCall(attr, typeParams) {
21
+ var _a, _b;
22
+ const type = ((_b = (_a = attr.metadata) === null || _a === void 0 ? void 0 : _a.derivedType) === null || _b === void 0 ? void 0 : _b.type) || attr.valueType || 'any';
23
+ const unique = attr.config.unique ? '.unique()' : '';
24
+ const index = attr.config.indexed ? '.indexed()' : '';
25
+ const required = attr.required ? '' : '.optional()';
26
+ return `i.${type}${typeParams !== null && typeParams !== void 0 ? typeParams : ''}()${unique}${index}${required}`;
27
+ }
28
+ function renderAttrProperty(name, attr, options = {}) {
29
+ return `${formatKey(name, options.keyOptions)}: ${renderAttrCall(attr, options.typeParams)}`;
30
+ }
31
+ function renderEntityProperty(name, attrs, options = {}) {
32
+ var _a;
33
+ const indent = (_a = options.indent) !== null && _a !== void 0 ? _a : DEFAULT_INDENT;
34
+ const keyOptions = options.keyOptions;
35
+ const attrBlock = (0, util_ts_1.sortedEntries)(attrs)
36
+ .map(([attrName, attrDef]) => {
37
+ var _a, _b;
38
+ return renderAttrProperty(attrName, attrDef, {
39
+ typeParams: (_b = (_a = options.typeParamsByAttr) === null || _a === void 0 ? void 0 : _a[attrName]) !== null && _b !== void 0 ? _b : null,
40
+ keyOptions,
41
+ });
42
+ })
43
+ .filter(Boolean);
44
+ const attrBlockText = options.trailingComma
45
+ ? (0, util_ts_1.joinWithTrailingSep)(attrBlock, ',\n', ',')
46
+ : attrBlock.join(',\n');
47
+ const inner = attrBlockText.length
48
+ ? `\n${(0, util_ts_1.indentLines)(attrBlockText, indent)}\n`
49
+ : '';
50
+ return `${formatKey(name, keyOptions)}: i.entity({${inner}})`;
51
+ }
52
+ function renderLinkValue(link, options = {}) {
53
+ var _a, _b, _c;
54
+ const indent = (_a = options.indent) !== null && _a !== void 0 ? _a : DEFAULT_INDENT;
55
+ const indentStr = ' '.repeat(indent);
56
+ const keyOptions = options.keyOptions;
57
+ const q = (_b = options.stringQuote) !== null && _b !== void 0 ? _b : "'";
58
+ const style = (_c = options.style) !== null && _c !== void 0 ? _c : 'js';
59
+ const forwardLines = [
60
+ `${formatKey('on', keyOptions)}: ${q}${link.forward.on}${q}`,
61
+ `${formatKey('has', keyOptions)}: ${q}${link.forward.has}${q}`,
62
+ `${formatKey('label', keyOptions)}: ${q}${link.forward.label}${q}`,
63
+ ];
64
+ if (link.forward.required) {
65
+ forwardLines.push(`${formatKey('required', keyOptions)}: true`);
66
+ }
67
+ if (link.forward.onDelete) {
68
+ forwardLines.push(`${formatKey('onDelete', keyOptions)}: ${q}${link.forward.onDelete}${q}`);
69
+ }
70
+ const reverseLines = [
71
+ `${formatKey('on', keyOptions)}: ${q}${link.reverse.on}${q}`,
72
+ `${formatKey('has', keyOptions)}: ${q}${link.reverse.has}${q}`,
73
+ `${formatKey('label', keyOptions)}: ${q}${link.reverse.label}${q}`,
74
+ ];
75
+ if (link.reverse.onDelete) {
76
+ reverseLines.push(`${formatKey('onDelete', keyOptions)}: ${q}${link.reverse.onDelete}${q}`);
77
+ }
78
+ const forwardBodyLines = style === 'json'
79
+ ? forwardLines
80
+ : forwardLines.map((line) => `${line},`);
81
+ const reverseBodyLines = style === 'json'
82
+ ? reverseLines
83
+ : reverseLines.map((line) => `${line},`);
84
+ return [
85
+ '{',
86
+ `${indentStr}${formatKey('forward', keyOptions)}: {`,
87
+ `${indentStr}${indentStr}${forwardBodyLines.join(`${style === 'json' ? ',' : ''}\n${indentStr}${indentStr}`)}`,
88
+ `${indentStr}}${style === 'json' ? ',' : ','}`,
89
+ `${indentStr}${formatKey('reverse', keyOptions)}: {`,
90
+ `${indentStr}${indentStr}${reverseBodyLines.join(`${style === 'json' ? ',' : ''}\n${indentStr}${indentStr}`)}`,
91
+ `${indentStr}}${style === 'json' ? '' : ','}`,
92
+ '}',
93
+ ].join('\n');
94
+ }
95
+ function renderLinkProperty(name, link, options = {}) {
96
+ return `${formatKey(name, options.keyOptions)}: ${renderLinkValue(link, options)}`;
97
+ }
98
+ function renderLinksObject(links, options = {}) {
99
+ var _a;
100
+ const indent = (_a = options.indent) !== null && _a !== void 0 ? _a : DEFAULT_INDENT;
101
+ const entries = (0, util_ts_1.sortedEntries)(links).map(([name, link]) => renderLinkProperty(name, link, {
102
+ indent,
103
+ keyOptions: options.keyOptions,
104
+ stringQuote: options.stringQuote,
105
+ style: options.style,
106
+ }));
107
+ if (!entries.length && !options.newlineForEmpty) {
108
+ return '{}';
109
+ }
110
+ const inner = entries.length ? (0, util_ts_1.indentLines)(entries.join(',\n'), indent) : '';
111
+ return `{\n${inner}\n}`;
112
+ }
113
+ function isValidIdentifier(name) {
114
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
115
+ }
116
+ //# sourceMappingURL=schemaCodegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaCodegen.js","sourceRoot":"","sources":["../../src/schemaCodegen.ts"],"names":[],"mappings":";;AAkCA,8BAMC;AAED,wCAUC;AAED,gDASC;AAED,oDA0BC;AAED,0CAyDC;AAED,gDASC;AAED,8CAkBC;AApLD,uCAA4E;AAE5E,MAAM,cAAc,GAAG,CAAC,CAAC;AA+BzB,SAAgB,SAAS,CAAC,IAAY,EAAE,UAA4B,EAAE;;IACpE,MAAM,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,GAAG,CAAC;IACnC,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,EAAE,CAAC;AACnC,CAAC;AAED,SAAgB,cAAc,CAC5B,IAA2C,EAC3C,UAA0B;;IAE1B,MAAM,IAAI,GACR,CAAA,MAAC,MAAA,IAAI,CAAC,QAAQ,0CAAE,WAAmB,0CAAE,IAAI,KAAI,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;IACvE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;IACpD,OAAO,KAAK,IAAI,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,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AC,CAAC,EAAE,CAAC;IAC7E,OAAO,MAAM,KAAK,KAAK,CAAC;AAC1B,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import type { AttrsDefs, DataAttrDef, LinkDef, LinksDef } from '@instantdb/core';\nimport { indentLines, joinWithTrailingSep, sortedEntries } from './util.ts';\n\nconst DEFAULT_INDENT = 2;\n\ntype AnyLink = LinkDef<any, any, any, any, any, any, any>;\n\ntype KeyFormatOptions = {\n alwaysQuote?: boolean;\n quote?: '\"' | \"'\";\n};\n\ntype EntityRenderOptions = {\n indent?: number;\n typeParamsByAttr?: Record<string, string | null | undefined>;\n keyOptions?: KeyFormatOptions;\n trailingComma?: boolean;\n};\n\ntype LinkRenderOptions = {\n indent?: number;\n keyOptions?: KeyFormatOptions;\n stringQuote?: '\"' | \"'\";\n style?: 'js' | 'json';\n};\n\ntype LinksObjectOptions = {\n indent?: number;\n newlineForEmpty?: boolean;\n keyOptions?: KeyFormatOptions;\n stringQuote?: '\"' | \"'\";\n style?: 'js' | 'json';\n};\n\nexport function formatKey(name: string, options: KeyFormatOptions = {}) {\n const quote = options.quote ?? \"'\";\n if (!options.alwaysQuote && isValidIdentifier(name)) {\n return name;\n }\n return `${quote}${name}${quote}`;\n}\n\nexport function renderAttrCall(\n attr: DataAttrDef<string, boolean, boolean>,\n typeParams?: string | null,\n) {\n const type =\n (attr.metadata?.derivedType as any)?.type || attr.valueType || 'any';\n const unique = attr.config.unique ? '.unique()' : '';\n const index = attr.config.indexed ? '.indexed()' : '';\n const required = attr.required ? '' : '.optional()';\n return `i.${type}${typeParams ?? ''}()${unique}${index}${required}`;\n}\n\nexport function renderAttrProperty(\n name: string,\n attr: DataAttrDef<string, boolean, boolean>,\n options: { typeParams?: string | null; keyOptions?: KeyFormatOptions } = {},\n) {\n return `${formatKey(name, options.keyOptions)}: ${renderAttrCall(\n attr,\n options.typeParams,\n )}`;\n}\n\nexport function renderEntityProperty(\n name: string,\n attrs: AttrsDefs,\n options: EntityRenderOptions = {},\n) {\n const indent = options.indent ?? DEFAULT_INDENT;\n const keyOptions = options.keyOptions;\n const attrBlock = sortedEntries(attrs)\n .map(([attrName, attrDef]) =>\n renderAttrProperty(\n attrName,\n attrDef,\n {\n typeParams: options.typeParamsByAttr?.[attrName] ?? null,\n keyOptions,\n },\n ),\n )\n .filter(Boolean);\n const attrBlockText = options.trailingComma\n ? joinWithTrailingSep(attrBlock, ',\\n', ',')\n : attrBlock.join(',\\n');\n const inner = attrBlockText.length\n ? `\\n${indentLines(attrBlockText, indent)}\\n`\n : '';\n return `${formatKey(name, keyOptions)}: i.entity({${inner}})`;\n}\n\nexport function renderLinkValue(\n link: AnyLink,\n options: LinkRenderOptions = {},\n) {\n const indent = options.indent ?? DEFAULT_INDENT;\n const indentStr = ' '.repeat(indent);\n const keyOptions = options.keyOptions;\n const q = options.stringQuote ?? \"'\";\n const style = options.style ?? 'js';\n const forwardLines = [\n `${formatKey('on', keyOptions)}: ${q}${link.forward.on}${q}`,\n `${formatKey('has', keyOptions)}: ${q}${link.forward.has}${q}`,\n `${formatKey('label', keyOptions)}: ${q}${link.forward.label}${q}`,\n ];\n if (link.forward.required) {\n forwardLines.push(`${formatKey('required', keyOptions)}: true`);\n }\n if (link.forward.onDelete) {\n forwardLines.push(\n `${formatKey('onDelete', keyOptions)}: ${q}${link.forward.onDelete}${q}`,\n );\n }\n\n const reverseLines = [\n `${formatKey('on', keyOptions)}: ${q}${link.reverse.on}${q}`,\n `${formatKey('has', keyOptions)}: ${q}${link.reverse.has}${q}`,\n `${formatKey('label', keyOptions)}: ${q}${link.reverse.label}${q}`,\n ];\n if (link.reverse.onDelete) {\n reverseLines.push(\n `${formatKey('onDelete', keyOptions)}: ${q}${link.reverse.onDelete}${q}`,\n );\n }\n\n const forwardBodyLines =\n style === 'json'\n ? forwardLines\n : forwardLines.map((line) => `${line},`);\n const reverseBodyLines =\n style === 'json'\n ? reverseLines\n : reverseLines.map((line) => `${line},`);\n\n return [\n '{',\n `${indentStr}${formatKey('forward', keyOptions)}: {`,\n `${indentStr}${indentStr}${forwardBodyLines.join(\n `${style === 'json' ? ',' : ''}\\n${indentStr}${indentStr}`,\n )}`,\n `${indentStr}}${style === 'json' ? ',' : ','}`,\n `${indentStr}${formatKey('reverse', keyOptions)}: {`,\n `${indentStr}${indentStr}${reverseBodyLines.join(\n `${style === 'json' ? ',' : ''}\\n${indentStr}${indentStr}`,\n )}`,\n `${indentStr}}${style === 'json' ? '' : ','}`,\n '}',\n ].join('\\n');\n}\n\nexport function renderLinkProperty(\n name: string,\n link: AnyLink,\n options: LinkRenderOptions = {},\n) {\n return `${formatKey(name, options.keyOptions)}: ${renderLinkValue(\n link,\n options,\n )}`;\n}\n\nexport function renderLinksObject(\n links: LinksDef<any>,\n options: LinksObjectOptions = {},\n) {\n const indent = options.indent ?? DEFAULT_INDENT;\n const entries = sortedEntries(links).map(([name, link]) =>\n renderLinkProperty(name, link, {\n indent,\n keyOptions: options.keyOptions,\n stringQuote: options.stringQuote,\n style: options.style,\n }),\n );\n if (!entries.length && !options.newlineForEmpty) {\n return '{}';\n }\n const inner = entries.length ? indentLines(entries.join(',\\n'), indent) : '';\n return `{\\n${inner}\\n}`;\n}\n\nfunction isValidIdentifier(name: string) {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);\n}\n"]}
@@ -10,4 +10,5 @@ import { i, type InstantRules } from '@instantdb/core';
10
10
  import { exchangeCodeForToken, exchangeRefreshToken } from './serverOAuth.ts';
11
11
  export { type InstantAPIPlatformSchema, type InstantDBOAuthAccessToken, type OAuthHandlerConfig, type OAuthScope, type InstantRules, OAuthHandler, InstantOAuthError, generateSchemaTypescriptFile, validateSchema, SchemaValidationError, generatePermsTypescriptFile, apiSchemaToInstantSchemaDef, schemaTypescriptFileToInstantSchema, version, translatePlanSteps, PlatformApi, ProgressPromise, exchangeCodeForToken, exchangeRefreshToken, i, };
12
12
  export { diffSchemas, convertTxSteps, isRenamePromptItem, type RenameResolveFn, type MigrationTx, type MigrationTxSpecific, type MigrationTxTypes, type Identifier, } from './migrations.ts';
13
+ export { formatKey, renderAttrCall, renderAttrProperty, renderEntityProperty, renderLinkValue, renderLinkProperty, renderLinksObject, } from './schemaCodegen.ts';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,YAAY,EACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,YAAY,EACZ,iBAAiB,EACjB,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,mCAAmC,EACnC,OAAO,EACP,kBAAkB,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ACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,CAAC,GACF,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -10,4 +10,5 @@ import { i } from '@instantdb/core';
10
10
  import { exchangeCodeForToken, exchangeRefreshToken } from "./serverOAuth.js";
11
11
  export { OAuthHandler, InstantOAuthError, generateSchemaTypescriptFile, validateSchema, SchemaValidationError, generatePermsTypescriptFile, apiSchemaToInstantSchemaDef, schemaTypescriptFileToInstantSchema, version, translatePlanSteps, PlatformApi, ProgressPromise, exchangeCodeForToken, exchangeRefreshToken, i, };
12
12
  export { diffSchemas, convertTxSteps, isRenamePromptItem, } from "./migrations.js";
13
+ export { formatKey, renderAttrCall, renderAttrProperty, renderEntityProperty, renderLinkValue, renderLinkProperty, renderLinksObject, } from "./schemaCodegen.js";
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAGL,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAEL,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAqB,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAML,YAAY,EACZ,iBAAiB,EACjB,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,mCAAmC,EACnC,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,CAAC,GACF,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,GAMnB,MAAM,iBAAiB,CAAC","sourcesContent":["import { InstantOAuthError, type OAuthScope } from './oauthCommon.ts';\nimport {\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n OAuthHandler,\n} from './oauth.ts';\nimport { generatePermsTypescriptFile } from './perms.ts';\nimport {\n type InstantAPIPlatformSchema,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n} from './schema.ts';\nimport {\n apiSchemaToInstantSchemaDef,\n PlatformApi,\n translatePlanSteps,\n} from './api.ts';\nimport { schemaTypescriptFileToInstantSchema } from './typescript-schema.ts';\n\nimport version from './version.ts';\nimport { ProgressPromise } from './ProgressPromise.ts';\nimport { i, type InstantRules } from '@instantdb/core';\nimport { exchangeCodeForToken, exchangeRefreshToken } from './serverOAuth.ts';\n\nexport {\n type InstantAPIPlatformSchema,\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n type OAuthScope,\n type InstantRules,\n OAuthHandler,\n InstantOAuthError,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n generatePermsTypescriptFile,\n apiSchemaToInstantSchemaDef,\n schemaTypescriptFileToInstantSchema,\n version,\n translatePlanSteps,\n PlatformApi,\n ProgressPromise,\n exchangeCodeForToken,\n exchangeRefreshToken,\n i,\n};\n\nexport {\n diffSchemas,\n convertTxSteps,\n isRenamePromptItem,\n type RenameResolveFn,\n type MigrationTx,\n type MigrationTxSpecific,\n type MigrationTxTypes,\n type Identifier,\n} from './migrations.ts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAGL,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAEL,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAqB,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAML,YAAY,EACZ,iBAAiB,EACjB,4BAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,mCAAmC,EACnC,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,CAAC,GACF,CAAC;AAEF,OAAO,EACL,WAAW,EACX,cAAc,EACd,kBAAkB,GAMnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC","sourcesContent":["import { InstantOAuthError, type OAuthScope } from './oauthCommon.ts';\nimport {\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n OAuthHandler,\n} from './oauth.ts';\nimport { generatePermsTypescriptFile } from './perms.ts';\nimport {\n type InstantAPIPlatformSchema,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n} from './schema.ts';\nimport {\n apiSchemaToInstantSchemaDef,\n PlatformApi,\n translatePlanSteps,\n} from './api.ts';\nimport { schemaTypescriptFileToInstantSchema } from './typescript-schema.ts';\n\nimport version from './version.ts';\nimport { ProgressPromise } from './ProgressPromise.ts';\nimport { i, type InstantRules } from '@instantdb/core';\nimport { exchangeCodeForToken, exchangeRefreshToken } from './serverOAuth.ts';\n\nexport {\n type InstantAPIPlatformSchema,\n type InstantDBOAuthAccessToken,\n type OAuthHandlerConfig,\n type OAuthScope,\n type InstantRules,\n OAuthHandler,\n InstantOAuthError,\n generateSchemaTypescriptFile,\n validateSchema,\n SchemaValidationError,\n generatePermsTypescriptFile,\n apiSchemaToInstantSchemaDef,\n schemaTypescriptFileToInstantSchema,\n version,\n translatePlanSteps,\n PlatformApi,\n ProgressPromise,\n exchangeCodeForToken,\n exchangeRefreshToken,\n i,\n};\n\nexport {\n diffSchemas,\n convertTxSteps,\n isRenamePromptItem,\n type RenameResolveFn,\n type MigrationTx,\n type MigrationTxSpecific,\n type MigrationTxTypes,\n type Identifier,\n} from './migrations.ts';\n\nexport {\n formatKey,\n renderAttrCall,\n renderAttrProperty,\n renderEntityProperty,\n renderLinkValue,\n renderLinkProperty,\n renderLinksObject,\n} from './schemaCodegen.ts';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,EACb,wBAAwB,EACxB,cAAc,EAIf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAKL,gBAAgB,EACjB,MA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sC,GAChD,iBAAiB,CAAC,sCAAsC,CAAC,CAAC;AAE5D,MAAM,MAAM,wBAAwB,GAChC,+BAA+B,GAC/B,kCAAkC,GAClC,6BAA6B,GAC7B,mCAAmC,GACnC,8BAA8B,GAC9B,oCAAoC,GACpC,gCAAgC,GAChC,sCAAsC,GACtC,qCAAqC,GACrC,sCAAsC,CAAC;AAgB3C,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,UAE/C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,UAE/C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,UAE9C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,UAE/C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,UAE/C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,sBAE/C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,sBAE/C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,UAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,sBAI9C;AAsCD,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,EAC/C,SAAS,EAAE,gBAAgB,EAC3B,iBAAiB,EAAE,MAAM,GACxB,MAAM,CA+DR;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,cAAc,GACzB,QAAQ,gBAAgB,EACxB,yBAAyB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,SA8DrD,CAAC"}
@@ -1,16 +1,10 @@
1
- import { indentLines, joinWithTrailingSep, sortedEntries, formatKey, } from "./util.js";
2
- function attrDefToCodeString([name, attr]) {
3
- var _a;
4
- const type = ((_a = attr.metadata.derivedType) === null || _a === void 0 ? void 0 : _a.type) || attr.valueType || 'any';
5
- const unique = attr.config.unique ? '.unique()' : '';
6
- const index = attr.config.indexed ? '.indexed()' : '';
7
- const required = attr.required ? '' : '.optional()';
8
- return `${formatKey(name)}: i.${type}()${unique}${index}${required}`;
9
- }
1
+ import { indentLines, joinWithTrailingSep, sortedEntries, } from "./util.js";
2
+ import { formatKey, renderEntityProperty, renderLinksObject, } from "./schemaCodegen.js";
10
3
  function entityDefToCodeStr(name, edef) {
11
- const attrBlock = joinWithTrailingSep(sortedEntries(edef.attrs).map(attrDefToCodeString), ',\n', ',');
12
- // a block of code for each entity
13
- return `${formatKey(name)}: i.entity({${attrBlock.length ? '\n' : ''}${indentLines(attrBlock, 2)}${attrBlock.length ? '\n' : ''}})`;
4
+ return renderEntityProperty(name, edef.attrs, {
5
+ keyOptions: { alwaysQuote: true, quote: '"' },
6
+ trailingComma: true,
7
+ });
14
8
  }
15
9
  export function identEtype(ident) {
16
10
  return ident[1];
@@ -54,7 +48,7 @@ function roomDefToCodeStr(room) {
54
48
  ret += `\n${indentLines(entityDefToCodeStr('presence', room.presence), 4)},`;
55
49
  }
56
50
  if (room.topics) {
57
- ret += `\n "topics": {`;
51
+ ret += `\n ${formatKey('topics', { alwaysQuote: true, quote: '"' })}: {`;
58
52
  for (const [topicName, topicConfig] of Object.entries(room.topics)) {
59
53
  ret += `\n${indentLines(entityDefToCodeStr(topicName, topicConfig), 6)},`;
60
54
  }
@@ -66,7 +60,7 @@ function roomDefToCodeStr(room) {
66
60
  function roomsCodeStr(rooms) {
67
61
  let ret = '{';
68
62
  for (const [roomType, roomDef] of Object.entries(rooms)) {
69
- ret += `\n ${formatKey(roomType)}: ${roomDefToCodeStr(roomDef)},`;
63
+ ret += `\n ${formatKey(roomType, { alwaysQuote: true, quote: '"' })}: ${roomDefToCodeStr(roomDef)},`;
70
64
  }
71
65
  ret += ret === '{' ? '}' : '\n}';
72
66
  return ret;
@@ -89,7 +83,11 @@ export function generateSchemaTypescriptFile(prevSchema, newSchema, instantModul
89
83
  // Take a look at this schema, and if everything looks good,
90
84
  // run \`push schema\` again to enforce the types.`
91
85
  : '';
92
- const linksEntriesCode = JSON.stringify(newSchema.links, null, 2).trim();
86
+ const linksEntriesCode = renderLinksObject(newSchema.links, {
87
+ keyOptions: { alwaysQuote: true, quote: '"' },
88
+ stringQuote: '"',
89
+ style: 'json',
90
+ });
93
91
  // rooms
94
92
  const rooms = (prevSchema === null || prevSchema === void 0 ? void 0 : prevSchema.rooms) || {};
95
93
  const roomsCode = roomsCodeStr(rooms);