@carbonorm/carbonnode 3.2.1 → 3.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonorm/carbonnode",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "browser": "dist/index.umd.js",
5
5
  "exports": {
6
6
  ".": {
@@ -75,7 +75,6 @@
75
75
  "build:index": "npx barrelsby -d ./src --delete --exclude '(jestHoc|\\.test|\\.d).(js|tsx?)$' --exportDefault --verbose",
76
76
  "build:generateRestBindings": "cd ./scripts/ && tsc --downlevelIteration --resolveJsonModule generateRestBindings.ts && mv generateRestBindings.js generateRestBindings.cjs",
77
77
  "generateRestBindings": "npm run build:generateRestBindings && node ./scripts/generateRestBindings.cjs",
78
- "generateRestBindings:assessorly": "npm run build:generateRestBindings && node ./scripts/generateRestBindings.cjs --react 'import Assessorly from \"../../fed/src/Assessorly\"; Assessorly.instance'",
79
78
  "c6": "npm run generateRestBindings"
80
79
  },
81
80
  "bin": {
@@ -38,9 +38,13 @@ interface iDefine{{TABLE_NAME_SHORT_PASCAL_CASE}} {
38
38
  {{/each}}
39
39
  }
40
40
 
41
- export type {{TABLE_NAME_SHORT_PASCAL_CASE}}PrimaryKeys = {{#PRIMARY_SHORT}}
42
- '{{this}}'{{#unless @last}} |{{else}};{{/unless}}
43
- {{/PRIMARY_SHORT}}
41
+ export type {{TABLE_NAME_SHORT_PASCAL_CASE}}PrimaryKeys = {{#if PRIMARY_SHORT.length}}
42
+ {{#each PRIMARY_SHORT}}
43
+ '{{this}}'{{#unless @last}} |{{/unless}}
44
+ {{/each}};
45
+ {{else}}
46
+ never;
47
+ {{/if}}
44
48
 
45
49
  export const {{TABLE_NAME_SHORT}}:
46
50
  iC6RestfulModel<
@@ -246,6 +246,9 @@ var parseSQLToTypeScript = function (sql) {
246
246
  var primaryKeys = primaryKeyMatch
247
247
  ? primaryKeyMatch[1].split(',').map(function (key) { return key.trim().replace(/`/g, ''); })
248
248
  : [];
249
+ var primaryKeysType = primaryKeys.length > 0
250
+ ? primaryKeys.map(function (pk) { return "'".concat(pk, "'"); }).join(' | ')
251
+ : 'never';
249
252
  // Extract foreign keys
250
253
  var foreignKeyRegex = /CONSTRAINT `([^`]+)` FOREIGN KEY \(`([^`]+)`\) REFERENCES `([^`]+)` \(`([^`]+)`\)( ON DELETE (\w+))?( ON UPDATE (\w+))?/g;
251
254
  var foreignKeyMatch = void 0;
@@ -289,6 +292,7 @@ var parseSQLToTypeScript = function (sql) {
289
292
  TABLE_NAME_SHORT_PASCAL_CASE: tableName.replace(MySQLDump.DB_PREFIX, '').split('_').map(capitalizeFirstLetter).join('_'),
290
293
  PRIMARY: primaryKeys.map(function (pk) { return "".concat(tableName, ".").concat(pk); }),
291
294
  PRIMARY_SHORT: primaryKeys,
295
+ PRIMARY_KEYS_TYPE: primaryKeysType,
292
296
  COLUMNS: {},
293
297
  COLUMNS_UPPERCASE: {},
294
298
  TYPE_VALIDATION: {},
@@ -315,6 +315,10 @@ const parseSQLToTypeScript = (sql: string) => {
315
315
  ? primaryKeyMatch[1].split(',').map(key => key.trim().replace(/`/g, ''))
316
316
  : [];
317
317
 
318
+ const primaryKeysType = primaryKeys.length > 0
319
+ ? primaryKeys.map(pk => `'${pk}'`).join(' | ')
320
+ : 'never';
321
+
318
322
  // Extract foreign keys
319
323
  const foreignKeyRegex: RegExp = /CONSTRAINT `([^`]+)` FOREIGN KEY \(`([^`]+)`\) REFERENCES `([^`]+)` \(`([^`]+)`\)( ON DELETE (\w+))?( ON UPDATE (\w+))?/g;
320
324
  let foreignKeyMatch: RegExpExecArray | null;
@@ -369,6 +373,7 @@ const parseSQLToTypeScript = (sql: string) => {
369
373
  TABLE_NAME_SHORT_PASCAL_CASE: tableName.replace(MySQLDump.DB_PREFIX, '').split('_').map(capitalizeFirstLetter).join('_'),
370
374
  PRIMARY: primaryKeys.map(pk => `${tableName}.${pk}`),
371
375
  PRIMARY_SHORT: primaryKeys,
376
+ PRIMARY_KEYS_TYPE: primaryKeysType,
372
377
  COLUMNS: {},
373
378
  COLUMNS_UPPERCASE: {},
374
379
  TYPE_VALIDATION: {},