mobiletto-orm-typedef-gen 2.2.20 → 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.
- package/lib/cjs/generate.d.ts +1 -1
- package/lib/cjs/generate.js +3 -14
- package/lib/esm/generate.d.ts +1 -1
- package/lib/esm/generate.js +3 -14
- package/package.json +2 -2
package/lib/cjs/generate.d.ts
CHANGED
|
@@ -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;
|
package/lib/cjs/generate.js
CHANGED
|
@@ -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
|
-
|
|
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/lib/esm/generate.d.ts
CHANGED
|
@@ -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;
|
package/lib/esm/generate.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "2.2.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "generate various files based on mobiletto-orm-typedef definitions",
|
|
6
6
|
"keywords": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"eslint": "^8.44.0",
|
|
53
53
|
"eslint-config-prettier": "^8.8.0",
|
|
54
54
|
"handlebars": "^4.7.7",
|
|
55
|
-
"mobiletto-orm-typedef": "^2.3.
|
|
55
|
+
"mobiletto-orm-typedef": "^2.3.19",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"prettier": "^3.0.0",
|
|
58
58
|
"tslint-config-prettier": "^1.18.0",
|