mobiletto-orm-typedef-gen 2.2.21 → 2.2.22

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.
@@ -15,4 +15,4 @@ export type GenerateOptions = {
15
15
  prepareContext?: (typeDef: MobilettoOrmTypeDef, ctx: Record<string, unknown>) => Record<string, unknown>;
16
16
  mobilettoOrmObjectPackage?: string;
17
17
  };
18
- export declare const generate: (typeDef: MobilettoOrmTypeDef | MobilettoOrmTypeDefConfig, templatePath: string, opts?: GenerateOptions) => string;
18
+ export declare const generate: (typeDef: MobilettoOrmTypeDef | MobilettoOrmTypeDefConfig, templatePath: string, opts?: GenerateOptions, ctx?: Record<string, object>) => string;
@@ -108,7 +108,7 @@ const defaultPrepareContext = (typeDef, ctx) => {
108
108
  };
109
109
  const VALID_TEMPLATE_FILE_EXT = [".ts.hbs", ".vue.hbs"];
110
110
  const validTemplateFile = (path) => !!VALID_TEMPLATE_FILE_EXT.find((ext) => path.endsWith(ext));
111
- export const generate = (typeDef, templatePath, opts) => {
111
+ export const generate = (typeDef, templatePath, opts, ctx) => {
112
112
  if (!(typeDef instanceof MobilettoOrmTypeDef)) {
113
113
  typeDef = new MobilettoOrmTypeDef(typeDef);
114
114
  }
@@ -125,19 +125,8 @@ export const generate = (typeDef, templatePath, opts) => {
125
125
  const decl = decls.pop();
126
126
  if (!decl)
127
127
  break;
128
- const typeContext = defaultPrepareContext(typeDef, {
129
- typeDef,
130
- name: decl.name,
131
- Name: capitalize(decl.name),
132
- fields: decl.fields,
133
- fieldNames: Object.keys(decl.fields),
134
- disclaimer: decls.length > 0 ? null : disclaimer,
135
- header: decls.length > 0 ? null : opts === null || opts === void 0 ? void 0 : opts.header,
136
- first,
137
- root: decl.root || false,
138
- typescript,
139
- mobilettoOrmObjectPackage,
140
- });
128
+ const typeContext = defaultPrepareContext(typeDef, Object.assign({ typeDef, name: decl.name, Name: capitalize(decl.name), fields: decl.fields, fieldNames: Object.keys(decl.fields), disclaimer: decls.length > 0 ? null : disclaimer, header: decls.length > 0 ? null : opts === null || opts === void 0 ? void 0 : opts.header, first, root: decl.root || false, typescript,
129
+ mobilettoOrmObjectPackage }, ctx));
141
130
  const preparedContext = (opts === null || opts === void 0 ? void 0 : opts.prepareContext) ? opts.prepareContext(typeDef, typeContext) : typeContext;
142
131
  first = false;
143
132
  typeContext.ctx = typeContext;
@@ -15,4 +15,4 @@ export type GenerateOptions = {
15
15
  prepareContext?: (typeDef: MobilettoOrmTypeDef, ctx: Record<string, unknown>) => Record<string, unknown>;
16
16
  mobilettoOrmObjectPackage?: string;
17
17
  };
18
- export declare const generate: (typeDef: MobilettoOrmTypeDef | MobilettoOrmTypeDefConfig, templatePath: string, opts?: GenerateOptions) => string;
18
+ export declare const generate: (typeDef: MobilettoOrmTypeDef | MobilettoOrmTypeDefConfig, templatePath: string, opts?: GenerateOptions, ctx?: Record<string, object>) => string;
@@ -108,7 +108,7 @@ const defaultPrepareContext = (typeDef, ctx) => {
108
108
  };
109
109
  const VALID_TEMPLATE_FILE_EXT = [".ts.hbs", ".vue.hbs"];
110
110
  const validTemplateFile = (path) => !!VALID_TEMPLATE_FILE_EXT.find((ext) => path.endsWith(ext));
111
- export const generate = (typeDef, templatePath, opts) => {
111
+ export const generate = (typeDef, templatePath, opts, ctx) => {
112
112
  if (!(typeDef instanceof MobilettoOrmTypeDef)) {
113
113
  typeDef = new MobilettoOrmTypeDef(typeDef);
114
114
  }
@@ -125,19 +125,8 @@ export const generate = (typeDef, templatePath, opts) => {
125
125
  const decl = decls.pop();
126
126
  if (!decl)
127
127
  break;
128
- const typeContext = defaultPrepareContext(typeDef, {
129
- typeDef,
130
- name: decl.name,
131
- Name: capitalize(decl.name),
132
- fields: decl.fields,
133
- fieldNames: Object.keys(decl.fields),
134
- disclaimer: decls.length > 0 ? null : disclaimer,
135
- header: decls.length > 0 ? null : opts === null || opts === void 0 ? void 0 : opts.header,
136
- first,
137
- root: decl.root || false,
138
- typescript,
139
- mobilettoOrmObjectPackage,
140
- });
128
+ const typeContext = defaultPrepareContext(typeDef, Object.assign({ typeDef, name: decl.name, Name: capitalize(decl.name), fields: decl.fields, fieldNames: Object.keys(decl.fields), disclaimer: decls.length > 0 ? null : disclaimer, header: decls.length > 0 ? null : opts === null || opts === void 0 ? void 0 : opts.header, first, root: decl.root || false, typescript,
129
+ mobilettoOrmObjectPackage }, ctx));
141
130
  const preparedContext = (opts === null || opts === void 0 ? void 0 : opts.prepareContext) ? opts.prepareContext(typeDef, typeContext) : typeContext;
142
131
  first = false;
143
132
  typeContext.ctx = typeContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto-orm-typedef-gen",
3
- "version": "2.2.21",
3
+ "version": "2.2.22",
4
4
  "type": "module",
5
5
  "description": "generate various files based on mobiletto-orm-typedef definitions",
6
6
  "keywords": [