New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@hapify/generator

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapify/generator - npm Package Compare versions

Comparing version
0.8.0
to
1.0.0
.eslintignore

Sorry, the diff of this file is not supported yet

+21
# Changelog
All notable changes to this project will be documented in this file. See
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# @hapify/generator 1.0.0 (2021-04-16)
### Features
* add generator package ([#17](https://github.com/hapify/hapify/issues/17)) ([5ac94ae](https://github.com/hapify/hapify/commit/5ac94ae190a21bf2b1c416d6f5e9641ac247794b))
### Dependencies
* **@hapify/ejs:** upgraded to 1.1.0
* **@hapify/syntax:** upgraded to 1.1.0
* **@hapify/vm:** upgraded to 1.2.0
export declare const Config: {
Generator: {
timeout: number;
};
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
exports.Config = {
Generator: {
timeout: 1000,
},
};
//# sourceMappingURL=Config.js.map
{"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACpB,SAAS,EAAE;QACT,OAAO,EAAE,IAAI;KACd;CACF,CAAC"}
import { NumberedError } from '../Interfaces';
export declare class EvaluationError extends Error implements NumberedError {
code: number;
name: string;
lineNumber: number;
columnNumber: number;
details: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EvaluationError = void 0;
class EvaluationError extends Error {
constructor() {
super(...arguments);
this.code = 2004;
this.name = 'GeneratorEvaluationError';
this.lineNumber = null;
this.columnNumber = null;
this.details = null;
}
}
exports.EvaluationError = EvaluationError;
//# sourceMappingURL=EvaluationError.js.map
{"version":3,"file":"EvaluationError.js","sourceRoot":"","sources":["../../src/errors/EvaluationError.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAgB,SAAQ,KAAK;IAA1C;;QACE,SAAI,GAAG,IAAI,CAAC;QAEZ,SAAI,GAAG,0BAA0B,CAAC;QAElC,eAAU,GAAW,IAAI,CAAC;QAE1B,iBAAY,GAAW,IAAI,CAAC;QAE5B,YAAO,GAAW,IAAI,CAAC;IACzB,CAAC;CAAA;AAVD,0CAUC"}
import { NumberedError } from '../Interfaces';
export declare class InternalError extends Error implements NumberedError {
code: number;
name: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InternalError = void 0;
class InternalError extends Error {
constructor() {
super(...arguments);
this.code = 2001;
this.name = 'GeneratorInternalError';
}
}
exports.InternalError = InternalError;
//# sourceMappingURL=InternalError.js.map
{"version":3,"file":"InternalError.js","sourceRoot":"","sources":["../../src/errors/InternalError.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAc,SAAQ,KAAK;IAAxC;;QACE,SAAI,GAAG,IAAI,CAAC;QAEZ,SAAI,GAAG,wBAAwB,CAAC;IAClC,CAAC;CAAA;AAJD,sCAIC"}
import { NumberedError } from '../Interfaces';
export declare class TimeoutError extends Error implements NumberedError {
code: number;
name: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeoutError = void 0;
class TimeoutError extends Error {
constructor() {
super(...arguments);
this.code = 2005;
this.name = 'GeneratorTimeoutError';
}
}
exports.TimeoutError = TimeoutError;
//# sourceMappingURL=TimeoutError.js.map
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../src/errors/TimeoutError.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAa,SAAQ,KAAK;IAAvC;;QACE,SAAI,GAAG,IAAI,CAAC;QAEZ,SAAI,GAAG,uBAAuB,CAAC;IACjC,CAAC;CAAA;AAJD,oCAIC"}
import { GeneratorResult, Model, Template } from '../Interfaces';
export declare class Generator {
/** Available generators */
private generators;
/**
* Run generation process for one model
* "forIds": A list of models ids to restrict generation to
* Throws an error if the template needs a model and no model is passed
*/
run(templates: Template[], models: Model[], forIds?: string[]): Promise<GeneratorResult[]>;
/** Only process the path */
path(path: string, modelName?: string): string;
/** Ensure error has a code and returns it */
private formatError;
/** Get generator instance from template.engine */
private getGeneratorForTemplate;
/**
* Run generation process for one model and one template
* Throws an error if the template rendering engine is unknown
*/
private one;
/**
* Run generation process for all models and one template
* Throws an error if the template rendering engine is unknown
*/
private all;
/** Convert the model to an object containing all its properties */
private explicitModel;
/** Convert the model to an object containing all its properties unless references and dependencies */
private explicitDeepModel;
/** Convert the model used for a reference. Get model description (first level) and remove non referencing fields */
private explicitReferenceModel;
/** Return all dependent models as deep models */
private explicitDependencies;
/** Map entity fields to target models */
private explicitReferences;
/** Get models using this model */
private explicitReferencedIn;
/** Extract and process fields from model */
private explicitFields;
/** Extract and process accesses from model */
private explicitAccesses;
/** Compute models properties from fields */
private explicitProperties;
/** Convert all the models to an array of objects containing all its properties */
private explicitAllModels;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Generator = void 0;
const InternalError_1 = require("../errors/InternalError");
const StringVariants_1 = require("../StringVariants");
const EJSGenerator_1 = require("./workers/EJSGenerator");
const HpfGenerator_1 = require("./workers/HpfGenerator");
const JavascriptGenerator_1 = require("./workers/JavascriptGenerator");
const CACHE_ENABLED = true;
class Generator {
constructor() {
/** Available generators */
this.generators = {
hpf: new HpfGenerator_1.HpfGenerator(),
js: new JavascriptGenerator_1.JavascriptGenerator(),
ejs: new EJSGenerator_1.EJSGenerator(),
};
}
/**
* Run generation process for one model
* "forIds": A list of models ids to restrict generation to
* Throws an error if the template needs a model and no model is passed
*/
run(templates, models, forIds) {
return __awaiter(this, void 0, void 0, function* () {
try {
// Create results stack
const output = [];
// Create a new cache context
const cache = {};
// For each template, run sub process
for (const template of templates) {
if (template.input === 'one') {
for (const model of models) {
if (forIds && !forIds.find((id) => id === model.id)) {
continue;
}
output.push(yield this.one(template, models, model, cache));
}
}
else {
output.push(yield this.all(template, models, cache));
}
}
return output;
}
catch (error) {
throw this.formatError(error);
}
});
}
/** Only process the path */
path(path, modelName) {
let output = path;
try {
// Quick exit
if (!modelName) {
return output;
}
const variants = StringVariants_1.StringVariants(modelName);
const keys = Object.keys(variants);
for (const key of keys) {
output = output.replace(new RegExp(`{${key}}`, 'g'), variants[key]);
}
return output;
}
catch (error) {
throw this.formatError(error);
}
}
/** Ensure error has a code and returns it */
formatError(error) {
// Error is already formatted ?
if (typeof error.code === 'undefined') {
const newError = new InternalError_1.InternalError(error.message);
newError.stack = error.stack;
return newError;
}
return error;
}
/** Get generator instance from template.engine */
getGeneratorForTemplate(template) {
if (typeof this.generators[template.engine] === 'undefined') {
throw new Error(`Unknown engine ${template.engine}`);
}
return this.generators[template.engine];
}
/**
* Run generation process for one model and one template
* Throws an error if the template rendering engine is unknown
*/
one(template, models, model, cache) {
return __awaiter(this, void 0, void 0, function* () {
// Compute path
const path = this.path(template.path, model.name);
// Get full model description
const input = this.explicitModel(models, model, cache);
// Compute content
const generator = this.getGeneratorForTemplate(template);
const content = yield generator.one(input, template);
return {
content,
path,
};
});
}
/**
* Run generation process for all models and one template
* Throws an error if the template rendering engine is unknown
*/
all(template, models, cache) {
return __awaiter(this, void 0, void 0, function* () {
// Compute path
const path = this.path(template.path);
// Get full models description
const input = this.explicitAllModels(models, cache);
// Compute content
const generator = this.getGeneratorForTemplate(template);
const content = yield generator.all(input, template);
return {
content,
path,
};
});
}
/** Convert the model to an object containing all its properties */
explicitModel(models, model, cache, depth = 0) {
// Return cache value if any
if (CACHE_ENABLED && depth === 0 && cache[model.id]) {
return cache[model.id];
}
const deepFields = this.explicitFields(model);
const accesses = this.explicitAccesses(model);
const references = this.explicitReferences(models, deepFields.list);
const fields = Object.assign(deepFields, {
references,
r: references,
});
const dependencies = this.explicitDependencies(model, fields.references);
const referencedIn = this.explicitReferencedIn(models, model);
const properties = Object.assign(this.explicitProperties(deepFields), {
hasDependencies: dependencies.list.length > 0,
isReferenced: referencedIn.length > 0,
});
// Create explicit model
const m = {
id: model.id,
name: model.name,
names: StringVariants_1.StringVariants(model.name),
fields,
f: fields,
properties,
p: properties,
accesses,
a: accesses,
dependencies,
d: dependencies,
referencedIn,
ri: referencedIn,
};
// Store cache
if (CACHE_ENABLED && depth === 0) {
cache[model.id] = m;
}
return m;
}
/** Convert the model to an object containing all its properties unless references and dependencies */
explicitDeepModel(model) {
const fields = this.explicitFields(model);
const properties = this.explicitProperties(fields);
const accesses = this.explicitAccesses(model);
return {
id: model.id,
name: model.name,
names: StringVariants_1.StringVariants(model.name),
fields,
f: fields,
properties,
p: properties,
accesses,
a: accesses,
};
}
/** Convert the model used for a reference. Get model description (first level) and remove non referencing fields */
explicitReferenceModel(model, filter) {
const fields = this.explicitFields(model);
const properties = this.explicitProperties(fields);
const accesses = this.explicitAccesses(model);
const filteredFields = fields.list.filter(filter);
filteredFields.f = filteredFields.filter;
return {
id: model.id,
name: model.name,
names: StringVariants_1.StringVariants(model.name),
fields: filteredFields,
f: filteredFields,
properties,
p: properties,
accesses,
a: accesses,
};
}
/** Return all dependent models as deep models */
explicitDependencies(model, references) {
// Create method to reduce references to dependencies
// A custom filter can be passed
// If the second argument is false, keep the self dependency
const dependencies = (filter = (f) => !!f, excludeSelf = true) => {
const duplicates = {};
return (references
// Apply custom filter
.filter(filter)
// Remove self
.filter((ref) => (excludeSelf ? ref.model.id !== model.id : true))
// Remove duplicates
.filter((ref) => {
if (duplicates[ref.value] === true) {
return false;
}
duplicates[ref.value] = true;
return true;
})
// Extract models
.map((ref) => ref.model));
};
// A boolean to determine if the model has a self dependency
const selfDependency = references.some((ref) => ref.model.id === model.id);
const allDependencies = dependencies();
return {
list: allDependencies,
l: allDependencies,
filter: dependencies,
f: dependencies,
self: selfDependency,
s: selfDependency,
};
}
/** Map entity fields to target models */
explicitReferences(models, fields) {
// Get reference fields
// Then explicit the reference. If no reference is found returns null (it will be filtered after)
const references = fields
.filter((f) => f.type === 'entity' && f.value)
.map((field) => {
const reference = models.find((m) => m.id === field.value);
// Nothing found
if (!reference) {
return null;
}
// Add reference to object
const subField = this.explicitDeepModel(reference);
field.model = subField;
field.m = subField;
return field;
})
.filter((f) => !!f);
// Add filter alias
references.f = references.filter;
return references;
}
/** Get models using this model */
explicitReferencedIn(models, model) {
// Filter referencing models
const extractReferencingFields = (f) => f.type === 'entity' && f.value === model.id;
const referencedIn = models
.filter((m) => m.fields.some(extractReferencingFields))
.map((m) => this.explicitReferenceModel(m, extractReferencingFields));
referencedIn.f = referencedIn.filter;
return referencedIn;
}
/** Extract and process fields from model */
explicitFields(model) {
// Get and format fields
const fields = model.fields.map((f) => {
const explicitField = Object.assign({ names: StringVariants_1.StringVariants(f.name) }, f);
// Deal with enums
if (f.type === 'enum' && f.value) {
const enumValues = f.value.map((v) => ({
name: v,
names: StringVariants_1.StringVariants(v),
}));
enumValues.f = enumValues.filter;
explicitField.enum = enumValues;
explicitField.e = enumValues;
}
return explicitField;
});
// Create explicit field groups
const primary = fields.find((f) => f.primary);
const unique = fields.filter((f) => f.unique);
const label = fields.filter((f) => f.label);
const searchableLabel = fields.filter((f) => f.label && f.searchable);
const nullable = fields.filter((f) => f.nullable);
const multiple = fields.filter((f) => f.multiple);
const embedded = fields.filter((f) => f.embedded);
const searchable = fields.filter((f) => f.searchable);
const sortable = fields.filter((f) => f.sortable);
const hidden = fields.filter((f) => f.hidden);
const internal = fields.filter((f) => f.internal);
const restricted = fields.filter((f) => f.restricted);
const ownership = fields.filter((f) => f.ownership);
// Create filter function
const filter = (callback = null) => (typeof callback === 'function' ? fields.filter(callback) : fields);
return {
list: fields,
l: fields,
filter,
f: filter,
primary,
pr: primary,
unique,
un: unique,
label,
lb: label,
nullable,
nu: nullable,
multiple,
ml: multiple,
embedded,
em: embedded,
searchable,
se: searchable,
sortable,
so: sortable,
hidden,
hd: hidden,
internal,
in: internal,
restricted,
rs: restricted,
ownership,
os: ownership,
searchableLabel,
sl: searchableLabel,
};
}
/** Extract and process accesses from model */
explicitAccesses(model) {
// Compute accesses sub-object for each action
// For each action, add a boolean for each access that denote if the access type is granted
const accesses = [];
const ordered = ['admin', 'owner', 'auth', 'guest'];
const indexes = {
admin: ordered.indexOf('admin'),
owner: ordered.indexOf('owner'),
auth: ordered.indexOf('auth'),
guest: ordered.indexOf('guest'),
};
const actions = Object.keys(model.accesses);
for (const action of actions) {
const accessIndex = ordered.indexOf(model.accesses[action]);
const description = {
action,
admin: accessIndex === indexes.admin,
owner: accessIndex === indexes.owner,
auth: accessIndex === indexes.auth,
guest: accessIndex === indexes.guest,
gteAdmin: accessIndex >= indexes.admin,
gteOwner: accessIndex >= indexes.owner,
gteAuth: accessIndex >= indexes.auth,
gteGuest: accessIndex >= indexes.guest,
lteAdmin: accessIndex <= indexes.admin,
lteOwner: accessIndex <= indexes.owner,
lteAuth: accessIndex <= indexes.auth,
lteGuest: accessIndex <= indexes.guest,
};
accesses.push(description);
}
// Get admin actions
const admin = accesses.filter((a) => a.admin);
// Get owner actions
const owner = accesses.filter((a) => a.owner);
// Get auth actions
const auth = accesses.filter((a) => a.auth);
// Get guest actions
const guest = accesses.filter((a) => a.guest);
// Get actions
const actionCreate = accesses.find((a) => a.action === 'create');
const actionRead = accesses.find((a) => a.action === 'read');
const actionUpdate = accesses.find((a) => a.action === 'update');
const actionRemove = accesses.find((a) => a.action === 'remove');
const actionSearch = accesses.find((a) => a.action === 'search');
const actionCount = accesses.find((a) => a.action === 'count');
// Pre-computed properties
const accessProperties = {
onlyAdmin: admin.length === accesses.length,
onlyOwner: owner.length === accesses.length,
onlyAuth: auth.length === accesses.length,
onlyGuest: guest.length === accesses.length,
maxAdmin: admin.length > 0 &&
owner.length === 0 &&
auth.length === 0 &&
guest.length === 0,
maxOwner: owner.length > 0 && auth.length === 0 && guest.length === 0,
maxAuth: auth.length > 0 && guest.length === 0,
maxGuest: guest.length > 0,
noAdmin: admin.length === 0,
noOwner: owner.length === 0,
noAuth: auth.length === 0,
noGuest: guest.length === 0,
hasAdmin: admin.length > 0,
hasOwner: owner.length > 0,
hasAuth: auth.length > 0,
hasGuest: guest.length > 0,
};
// Create filter function
const filterAccess = (func = null) => typeof func === 'function' ? accesses.filter(func) : accesses;
return {
list: accesses,
l: accesses,
filter: filterAccess,
f: filterAccess,
properties: accessProperties,
p: accessProperties,
// By access
admin,
ad: admin,
owner,
ow: owner,
auth,
au: auth,
guest,
gs: guest,
// By actions
create: actionCreate,
c: actionCreate,
read: actionRead,
r: actionRead,
update: actionUpdate,
u: actionUpdate,
remove: actionRemove,
d: actionRemove,
search: actionSearch,
s: actionSearch,
count: actionCount,
n: actionCount,
};
}
/** Compute models properties from fields */
explicitProperties(fields) {
return {
fieldsCount: fields.list.length,
hasPrimary: !!fields.primary,
hasUnique: fields.unique.length > 0,
hasLabel: fields.label.length > 0,
hasNullable: fields.nullable.length > 0,
hasMultiple: fields.multiple.length > 0,
hasEmbedded: fields.embedded.length > 0,
hasSearchable: fields.searchable.length > 0,
hasSortable: fields.sortable.length > 0,
hasHidden: fields.hidden.length > 0,
hasInternal: fields.internal.length > 0,
hasRestricted: fields.restricted.length > 0,
hasOwnership: fields.ownership.length > 0,
hasSearchableLabel: fields.searchableLabel.length > 0,
mainlyHidden: fields.list.length < 2 * fields.hidden.length,
mainlyInternal: fields.list.length < 2 * fields.internal.length,
isGeolocated: fields.list.filter((f) => f.type === 'number' && f.subtype === 'latitude').length > 0 &&
fields.list.filter((f) => f.type === 'number' && f.subtype === 'longitude').length > 0,
isGeoSearchable: fields.list.filter((f) => f.type === 'number' && f.subtype === 'latitude' && f.searchable).length > 0 &&
fields.list.filter((f) => f.type === 'number' && f.subtype === 'longitude' && f.searchable).length > 0,
};
}
/** Convert all the models to an array of objects containing all its properties */
explicitAllModels(models, cache) {
return models.map((mod) => this.explicitModel(models, mod, cache));
}
}
exports.Generator = Generator;
//# sourceMappingURL=Generator.js.map
{"version":3,"file":"Generator.js","sourceRoot":"","sources":["../../src/generators/Generator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAwD;AA+BxD,sDAAmD;AACnD,yDAAsD;AACtD,yDAAsD;AACtD,uEAAoE;AAOpE,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAa,SAAS;IAAtB;QACE,2BAA2B;QACnB,eAAU,GAAyC;YACzD,GAAG,EAAE,IAAI,2BAAY,EAAE;YACvB,EAAE,EAAE,IAAI,yCAAmB,EAAE;YAC7B,GAAG,EAAE,IAAI,2BAAY,EAAE;SACxB,CAAC;IA4iBJ,CAAC;IA1iBC;;;;OAIG;IACG,GAAG,CACP,SAAqB,EACrB,MAAe,EACf,MAAiB;;YAEjB,IAAI;gBACF,uBAAuB;gBACvB,MAAM,MAAM,GAAsB,EAAE,CAAC;gBACrC,6BAA6B;gBAC7B,MAAM,KAAK,GAAU,EAAE,CAAC;gBACxB,qCAAqC;gBACrC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;oBAChC,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,EAAE;wBAC5B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;4BAC1B,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE;gCACnD,SAAS;6BACV;4BACD,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;yBAC7D;qBACF;yBAAM;wBACL,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CA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AAC,CAAC,GAAU,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF;AAljBD,8BAkjBC"}
import { ExplicitModel, GenerationContext, GeneratorWorker, Template } from '../../Interfaces';
export declare abstract class BaseGenerator implements GeneratorWorker {
one(model: ExplicitModel, template: Template): string;
all(models: ExplicitModel[], template: Template): string;
/** Append file name to error details if applicable */
protected appendFileName(error: Error, template: Template): Error;
private errorIsEvaluationError;
protected abstract eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseGenerator = void 0;
class BaseGenerator {
one(model, template) {
try {
return this.eval(template.content, {
model,
m: model,
});
}
catch (error) {
throw this.appendFileName(error, template);
}
}
all(models, template) {
try {
return this.eval(template.content, {
models,
m: models,
});
}
catch (error) {
throw this.appendFileName(error, template);
}
}
/** Append file name to error details if applicable */
appendFileName(error, template) {
if (this.errorIsEvaluationError(error)) {
error.details += `\nFile: ${template.path}`;
}
return error;
}
errorIsEvaluationError(error) {
return typeof error.lineNumber !== 'undefined';
}
}
exports.BaseGenerator = BaseGenerator;
//# sourceMappingURL=BaseGenerator.js.map
{"version":3,"file":"BaseGenerator.js","sourceRoot":"","sources":["../../../src/generators/workers/BaseGenerator.ts"],"names":[],"mappings":";;;AAQA,MAAsB,aAAa;IACjC,GAAG,CAAC,KAAoB,EAAE,QAAkB;QAC1C,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;gBACjC,KAAK;gBACL,CAAC,EAAE,KAAK;aACT,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;SAC5C;IACH,CAAC;IAED,GAAG,CAAC,MAAuB,EAAE,QAAkB;QAC7C,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;gBACjC,MAAM;gBACN,CAAC,EAAE,MAAM;aACV,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;SAC5C;IACH,CAAC;IAED,sDAAsD;IAC5C,cAAc,CAAC,KAAY,EAAE,QAAkB;QACvD,IAAI,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE;YACtC,KAAK,CAAC,OAAO,IAAI,WAAW,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC7C;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,sBAAsB,CAAC,KAAY;QACzC,OAAO,OAAyB,KAAM,CAAC,UAAU,KAAK,WAAW,CAAC;IACpE,CAAC;CAGF;AApCD,sCAoCC"}
import { GenerationContext } from '../../Interfaces';
import { BaseGenerator } from './BaseGenerator';
export declare class EJSGenerator extends BaseGenerator {
protected eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EJSGenerator = void 0;
const ejs_1 = require("@hapify/ejs");
const Config_1 = require("../../Config");
const BaseGenerator_1 = require("./BaseGenerator");
const HpfOptions = { timeout: Config_1.Config.Generator.timeout };
class EJSGenerator extends BaseGenerator_1.BaseGenerator {
eval(content, context) {
return new ejs_1.HapifyEJS(HpfOptions).run(content, context);
}
}
exports.EJSGenerator = EJSGenerator;
//# sourceMappingURL=EJSGenerator.js.map
{"version":3,"file":"EJSGenerator.js","sourceRoot":"","sources":["../../../src/generators/workers/EJSGenerator.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC,yCAAsC;AAEtC,mDAAgD;AAEhD,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,eAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;AAEzD,MAAa,YAAa,SAAQ,6BAAa;IACnC,IAAI,CAAC,OAAe,EAAE,OAA0B;QACxD,OAAO,IAAI,eAAS,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACF;AAJD,oCAIC"}
import { GenerationContext } from '../../Interfaces';
import { BaseGenerator } from './BaseGenerator';
export declare class HpfGenerator extends BaseGenerator {
protected eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HpfGenerator = void 0;
const syntax_1 = require("@hapify/syntax");
const Config_1 = require("../../Config");
const BaseGenerator_1 = require("./BaseGenerator");
const HpfOptions = { timeout: Config_1.Config.Generator.timeout };
class HpfGenerator extends BaseGenerator_1.BaseGenerator {
eval(content, context) {
return syntax_1.HapifySyntax.run(content, context.m, HpfOptions);
}
}
exports.HpfGenerator = HpfGenerator;
//# sourceMappingURL=HpfGenerator.js.map
{"version":3,"file":"HpfGenerator.js","sourceRoot":"","sources":["../../../src/generators/workers/HpfGenerator.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAE9C,yCAAsC;AAEtC,mDAAgD;AAEhD,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,eAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;AAEzD,MAAa,YAAa,SAAQ,6BAAa;IACnC,IAAI,CAAC,OAAe,EAAE,OAA0B;QACxD,OAAO,qBAAY,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;CACF;AAJD,oCAIC"}
import { GenerationContext } from '../../Interfaces';
import { BaseGenerator } from './BaseGenerator';
export declare class JavascriptGenerator extends BaseGenerator {
protected eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JavascriptGenerator = void 0;
const vm_1 = require("@hapify/vm");
const Config_1 = require("../../Config");
const EvaluationError_1 = require("../../errors/EvaluationError");
const TimeoutError_1 = require("../../errors/TimeoutError");
const BaseGenerator_1 = require("./BaseGenerator");
class JavascriptGenerator extends BaseGenerator_1.BaseGenerator {
eval(content, context) {
try {
return new vm_1.HapifyVM({ timeout: Config_1.Config.Generator.timeout }).run(content, context);
}
catch (error) {
if (error.code === 6003) {
throw new TimeoutError_1.TimeoutError(`Template processing timed out (${Config_1.Config.Generator.timeout}ms)`);
}
if (error.code === 6002) {
// Clone error
const evalError = new EvaluationError_1.EvaluationError(error.message);
evalError.details = `Error: ${evalError.message}. Line: ${error.lineNumber}, Column: ${error.columnNumber}`;
evalError.lineNumber = error.lineNumber;
evalError.columnNumber = error.columnNumber;
throw evalError;
}
throw error;
}
}
}
exports.JavascriptGenerator = JavascriptGenerator;
//# sourceMappingURL=JavascriptGenerator.js.map
{"version":3,"file":"JavascriptGenerator.js","sourceRoot":"","sources":["../../../src/generators/workers/JavascriptGenerator.ts"],"names":[],"mappings":";;;AAAA,mCAA4E;AAE5E,yCAAsC;AACtC,kEAA+D;AAC/D,4DAAyD;AAEzD,mDAAgD;AAEhD,MAAa,mBAAoB,SAAQ,6BAAa;IAC1C,IAAI,CAAC,OAAe,EAAE,OAA0B;QACxD,IAAI;YACF,OAAO,IAAI,aAAQ,CAAC,EAAE,OAAO,EAAE,eAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAC5D,OAAO,EACP,OAAO,CACR,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;gBACvB,MAAM,IAAI,2BAAY,CACpB,kCAAkC,eAAM,CAAC,SAAS,CAAC,OAAO,KAAK,CAChE,CAAC;aACH;YACD,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;gBACvB,cAAc;gBACd,MAAM,SAAS,GAAG,IAAI,iCAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACrD,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,CAAC,OAAO,WAC5C,KAA2B,CAAC,UAC/B,aAAc,KAA2B,CAAC,YAAY,EAAE,CAAC;gBACzD,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;gBACxC,SAAS,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;gBAC5C,MAAM,SAAS,CAAC;aACjB;YACD,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF;AA1BD,kDA0BC"}
export interface NameInterpolable {
/** The name of the object, as the user entered it */
name: string;
/** All names computed from the `name` property */
names: StringVariations;
}
export declare type FieldType = 'boolean' | 'number' | 'string' | 'enum' | 'datetime' | 'entity' | 'object' | 'file';
export declare type FieldSubType = 'integer' | 'float' | 'latitude' | 'longitude' | 'email' | 'password' | 'url' | 'text' | 'rich' | 'date' | 'time' | 'image' | 'video' | 'audio' | 'document' | 'oneOne' | 'oneMany' | 'manyOne' | 'manyMany';
export declare type FieldValueType<T> = T extends 'entity' ? string : T extends 'enum' ? string[] : null;
export interface Field<T extends FieldType = FieldType> {
/** The field's name */
name: string;
/** The field's type */
type: T;
/** The field's subtype */
subtype: FieldSubType | null;
/**
* Value of the fields. Used if the type is entity or enum.
* - Entity: The UUID string of the targeted model
* - Enum: list of enum values
*/
value: FieldValueType<T>;
/** Should be used as a primary key or not */
primary: boolean;
/** Should be used as a unique key or not */
unique: boolean;
/** Should be used as a label or not */
label: boolean;
/** Denotes if the field can be empty or not */
nullable: boolean;
/** Denotes if the field is an array of values */
multiple: boolean;
/** Indicate whether the field is embedded (should be always exposed explicitly) */
embedded: boolean;
/** Indicate whether the field is searchable or not */
searchable: boolean;
/** Indicate whether the field is sortable or not */
sortable: boolean;
/** Indicate whether the field is hidden (should not be exposed) */
hidden: boolean;
/** Indicate whether the field is for an internal use only (should not be defined by an user) */
internal: boolean;
/** Indicate whether the field is restricted to authorized roles (should only be defined by an admin) */
restricted: boolean;
/** Indicate that this field defines the owner of the entity */
ownership: boolean;
}
/**
* Possible values for actions' access:
* - admin (Denotes if the access is restricted to the admins)
* - owner (Denotes if the access is restricted to the owner of the resource)
* - authenticated (Denotes if the access is restricted to authenticated users)
* - guest (Denotes if the access is not restricted)
*/
export declare type Access = 'admin' | 'owner' | 'auth' | 'guest';
/** Define the access for each available action */
export interface Accesses {
create: Access;
read: Access;
update: Access;
remove: Access;
search: Access;
count: Access;
}
/** Possible actions */
export declare type Action = keyof Accesses;
export interface Model {
/** The model's unique id */
id: string;
/** The model's name */
name: string;
/** The fields of the model */
fields: Field[];
/** The model privacy access */
accesses: Accesses;
}
export declare type Engine = 'hpf' | 'js' | 'ejs';
export declare type Input = 'one' | 'all';
export interface Template {
/** The template's path */
path: string;
/** The template's type */
engine: Engine;
/** Denotes if the template has to to be ran for one or all models */
input: Input;
/** The template's content */
content: string;
}
export interface AliasedArray<T> extends Array<T> {
/** Alias of `filter` */
f(callback: (value: T, index: number, array: T[]) => value is T, thisArg?: any): T[];
}
interface BaseExplicitModel extends NameInterpolable {
/** An unique id */
id: string;
/** An object containing pre-computed properties from fields */
properties: ExplicitDeepModelProperties;
/** Alias of `p` */
p: ExplicitDeepModelProperties;
/** An object containing all action's accesses grouped by action or restriction */
accesses: ExplicitModelAccesses;
/** Alias of `accesses` */
a: ExplicitModelAccesses;
}
export interface ExplicitModel extends BaseExplicitModel {
/** An object containing all fields, grouped in different arrays */
fields: ExplicitModelFields;
/** Alias of `fields` */
f: ExplicitModelFields;
/** An object containing pre-computed properties from fields */
properties: ExplicitModelProperties;
/** Alias of `p` */
p: ExplicitModelProperties;
/** Non-deep model only. An object containing dependencies (to other models) of this model. A model has a dependency if one of this field is of type `entity` */
dependencies: ExplicitModelDependencies;
/** Alias of `dependencies` */
d: ExplicitModelDependencies;
/** Non-deep model only. An array containing models that refer to this one. These models are added as "deep models" */
referencedIn: AliasedArray<ExplicitReferenceModel>;
/** Alias of `referencedIn` */
ri: AliasedArray<ExplicitReferenceModel>;
}
export interface ExplicitDeepModel extends BaseExplicitModel {
/** An object containing all fields, grouped in different arrays */
fields: ExplicitDeepModelFields;
/** Alias of `fields` */
f: ExplicitDeepModelFields;
}
export interface ExplicitReferenceModel extends BaseExplicitModel {
/** An array containing fields referencing the parent the model */
fields: AliasedArray<ExplicitField>;
/** Alias of `fields` */
f: AliasedArray<ExplicitField>;
}
export declare type ExplicitEnum = NameInterpolable;
export interface ExplicitField<T extends FieldType = FieldType> extends Field<T>, NameInterpolable {
}
export interface ExplicitReferenceField extends ExplicitField<'entity'> {
/** The target model object if the field is of type `entity` */
model: ExplicitDeepModel;
/** Alias of `model` */
m: ExplicitDeepModel;
}
export interface ExplicitEnumField extends ExplicitField<'enum'> {
/** The list of string variations for the enum */
enum: AliasedArray<ExplicitEnum>;
/** Alias of `enum` */
e: AliasedArray<ExplicitEnum>;
}
export interface ExplicitDeepModelFields {
/** An array containing all fields of the model */
list: ExplicitField[];
/** Alias of `list` */
l: ExplicitField[];
/** The primary field of the model. `null` if no primary field is defined. */
primary: ExplicitField | undefined;
/** Alias of `primary` */
pr: ExplicitField | undefined;
/** An array containing all fields flagged as `unique` */
unique: ExplicitField[];
/** Alias of `unique` */
un: ExplicitField[];
/** An array containing all fields flagged as `label` */
label: ExplicitField[];
/** Alias of `label` */
lb: ExplicitField[];
/** An array containing all fields flagged as `nullable` */
nullable: ExplicitField[];
/** Alias of `nullable` */
nu: ExplicitField[];
/** An array containing all fields flagged as `multiple` */
multiple: ExplicitField[];
/** Alias of `multiple` */
ml: ExplicitField[];
/** An array containing all fields flagged as `embedded` */
embedded: ExplicitField[];
/** Alias of `embedded` */
em: ExplicitField[];
/** An array containing all fields flagged as `searchable` */
searchable: ExplicitField[];
/** Alias of `searchable` */
se: ExplicitField[];
/** An array containing all fields flagged as `sortable` */
sortable: ExplicitField[];
/** Alias of `sortable` */
so: ExplicitField[];
/** An array containing all fields flagged as `hidden` */
hidden: ExplicitField[];
/** Alias of `hidden` */
hd: ExplicitField[];
/** An array containing all fields flagged as `internal` */
internal: ExplicitField[];
/** Alias of `internal` */
in: ExplicitField[];
/** An array containing all fields flagged as `restricted` */
restricted: ExplicitField[];
/** Alias of `restricted` */
rs: ExplicitField[];
/** An array containing all fields flagged as `ownership` */
ownership: ExplicitField[];
/** Alias of `ownership` */
os: ExplicitField[];
/** An array containing all fields flagged as `label` and `searchable`. Useful for quick-search by label. */
searchableLabel: ExplicitField[];
/** Alias of `searchableLabel` */
sl: ExplicitField[];
/** A function for filtering fields with a custom rule. Equivalent of `model.fields.list.filter` */
filter: ExplicitFieldsFilterFunction;
/** Alias of `filter` */
f: ExplicitFieldsFilterFunction;
}
export interface ExplicitModelFields extends ExplicitDeepModelFields {
/** Non-deep model only. An array containing all fields of type `entity`. */
references: AliasedArray<ExplicitReferenceField>;
/** Alias of `references` */
r: AliasedArray<ExplicitReferenceField>;
}
export declare type ExplicitFieldsFilterFunction = (callback: ((value: ExplicitField, index: number, array: ExplicitField[]) => boolean) | null) => ExplicitField[];
export interface ExplicitModelDependencies {
/** An array containing all dependency models, but self. These models are added as "deep models" */
list: ExplicitDeepModel[];
/** Alias of `list` */
l: ExplicitDeepModel[];
/** A boolean indicating if this model has a self-dependency */
self: boolean;
/** Alias of `self` */
s: boolean;
/** A function to filter dependencies */
filter: ExplicitModelDependenciesFilter;
/** Alias of `filter` */
f: ExplicitModelDependenciesFilter;
}
/**
* First argument (function - default `(f) => !!f`): The filtering function receiving the referencer field (the entity field)
* Second argument (boolean - default `true`): A boolean indicating if we should exclude the self dependency.
*/
export declare type ExplicitModelDependenciesFilter = (filter?: (field: ExplicitField) => boolean, excludeSelf?: boolean) => ExplicitDeepModel[];
export interface ExplicitDeepModelProperties {
/** The number of fields contained in the model */
fieldsCount: number;
/** Denotes if the model has a primary field */
hasPrimary: boolean;
/** Denotes if the model has at least one unique field */
hasUnique: boolean;
/** Denotes if the model has at least one label field */
hasLabel: boolean;
/** Denotes if the model has at least one nullable field */
hasNullable: boolean;
/** Denotes if the model has at least one multiple field */
hasMultiple: boolean;
/** Denotes if the model has at least one embedded field */
hasEmbedded: boolean;
/** Denotes if the model has at least one searchable field */
hasSearchable: boolean;
/** Denotes if the model has at least one sortable field */
hasSortable: boolean;
/** Denotes if the model has at least one hidden field */
hasHidden: boolean;
/** Denotes if the model has at least one internal field */
hasInternal: boolean;
/** Denotes if the model has at least one restricted field */
hasRestricted: boolean;
/** Denotes if the model has at least one ownership field */
hasOwnership: boolean;
/** Denotes if the model has at least one field marked as label and also searchable */
hasSearchableLabel: boolean;
/** Denotes if most of the fields are hidden (strictly) */
mainlyHidden: boolean;
/** Denotes if most of the fields are internal (strictly) */
mainlyInternal: boolean;
/** Denotes if the model contains at least one latitude field and one longitude field */
isGeolocated: boolean;
/** Denotes if the model contains at least one searchable latitude field and one searchable longitude field */
isGeoSearchable: boolean;
}
export interface ExplicitModelProperties extends ExplicitDeepModelProperties {
/** Denotes if the model has dependencies to other models or itself (through an `entity` field) */
hasDependencies: boolean;
/** Denotes if the model is referenced by other models */
isReferenced: boolean;
}
export interface ExplicitAccesses {
/** The name of the action */
action: Action;
/** Indicates if the selected access is `admin` */
admin: boolean;
/** Indicates if the selected access is `owner` */
owner: boolean;
/** Indicates if the selected access is `authenticated` */
auth: boolean;
/** Indicates if the selected access is `guest` */
guest: boolean;
/** Denotes if the selected access is greater or equal than `admin` (should always be `true`) */
gteAdmin: boolean;
/** Denotes if the selected access is greater or equal than `owner` */
gteOwner: boolean;
/** Denotes if the selected access is greater or equal than `authenticated` */
gteAuth: boolean;
/** Denotes if the selected access is greater or equal than `guest` */
gteGuest: boolean;
/** Denotes if the selected access is less or equal than `admin` */
lteAdmin: boolean;
/** Denotes if the selected access is less or equal than `owner` */
lteOwner: boolean;
/** Denotes if the selected access is less or equal than `authenticated` */
lteAuth: boolean;
/** Denotes if the selected access is less or equal than `guest` (should always be `true`) */
lteGuest: boolean;
}
export interface ExplicitModelAccessProperties {
/** Denotes if the model only contains actions restricted to `admin` */
onlyAdmin: boolean;
/** Denotes if the model only contains actions restricted to `owner` */
onlyOwner: boolean;
/** Denotes if the model only contains actions restricted to `authenticated` */
onlyAuth: boolean;
/** Denotes if the model only contains actions restricted to `guest` */
onlyGuest: boolean;
/** Denotes if the most permissive access is `admin` */
maxAdmin: boolean;
/** Denotes if the most permissive access is `owner` */
maxOwner: boolean;
/** Denotes if the most permissive access is `authenticated` */
maxAuth: boolean;
/** Denotes if the most permissive access is `guest` */
maxGuest: boolean;
/** Denotes if there is no action restricted to `admin` */
noAdmin: boolean;
/** Denotes if there is no action restricted to `owner` */
noOwner: boolean;
/** Denotes if there is no action restricted to `authenticated` */
noAuth: boolean;
/** Denotes if there is no action restricted to `guest` */
noGuest: boolean;
/** Denotes if there is at least one action restricted to `admin` */
hasAdmin: boolean;
/** Denotes if there is at least one action restricted to `owner` */
hasOwner: boolean;
/** Denotes if there is at least one action restricted to `authenticated` */
hasAuth: boolean;
/** Denotes if there is at least one action restricted to `guest` */
hasGuest: boolean;
}
export declare type ExplicitModelAccessFilter = (func: (a: ExplicitAccesses) => boolean | null) => ExplicitAccesses[];
export interface ExplicitModelAccesses {
/** An array containing all action's accesses of the model. */
list: ExplicitAccesses[];
/** Alias of `list` */
l: ExplicitAccesses[];
/** A function for filtering action's accesses with a custom rule. Equivalent of `model.accesses.list.filter`. */
filter: ExplicitModelAccessFilter;
/** Alias of `filter` */
f: ExplicitModelAccessFilter;
/** An object containing pre-computed properties from action's accesses. */
properties: ExplicitModelAccessProperties;
/** Alias of `properties` */
p: ExplicitModelAccessProperties;
/** An array containing all action's accesses restricted to `admin`. */
admin: ExplicitAccesses[];
/** Alias of `admin` */
ad: ExplicitAccesses[];
/** An array containing all action's accesses restricted to `owner`. */
owner: ExplicitAccesses[];
/** Alias of `owner` */
ow: ExplicitAccesses[];
/** An array containing all action's accesses restricted to `authenticated`. */
auth: ExplicitAccesses[];
/** Alias of `auth` */
au: ExplicitAccesses[];
/** An array containing all action's accesses restricted to `guest`. */
guest: ExplicitAccesses[];
/** Alias of `guest` */
gs: ExplicitAccesses[];
/** An object containing the `create` action's access. */
create: ExplicitAccesses;
/** Alias of `create` */
c: ExplicitAccesses;
/** An object containing the `read` action's access. */
read: ExplicitAccesses;
/** Alias of `read` */
r: ExplicitAccesses;
/** An object containing the `update` action's access. */
update: ExplicitAccesses;
/** Alias of `update` */
u: ExplicitAccesses;
/** An object containing the `delete` action's access. */
remove: ExplicitAccesses;
/** Alias of `remove` */
d: ExplicitAccesses;
/** An object containing the `search` action's access. */
search: ExplicitAccesses;
/** Alias of `search` */
s: ExplicitAccesses;
/** An object containing the `count` action's access. */
count: ExplicitAccesses;
/** Alias of `count` */
n: ExplicitAccesses;
}
export interface StringVariations {
/** The string of the field, as the user entered it. Example `fiRst Name`. */
raw: string;
/** The string with hyphens and lower case. Example `first-name`. */
kebab: string;
/** The string with underscores and lower case. Example `first_name`. */
snake: string;
/** The string with hyphens and first letters capitalized. Example `First-Name`. */
header: string;
/** The string with underscores and upper case. Example `FIRST_NAME`. */
constant: string;
/** The string with hyphens and upper case. Example `FIRST-NAME`. */
big: string;
/** The string as words with upper case on first letters. Example `First Name`. */
capital: string;
/** The string as words in lower case. Example `first name`. */
lower: string;
/** The string as words in upper case. Example `FIRST NAME`. */
upper: string;
/** The string joined and lower case. Example `firstname`. */
compact: string;
/** The string as upper camel case. Example `FirstName`. */
pascal: string;
/** The string as lower camel case. Example `firstName`. */
camel: string;
}
export declare type StringVariationType = keyof StringVariations;
export interface GeneratorWorker {
/** Run generation process for one model */
one(model: ExplicitModel, template: Template): string | Promise<string>;
/** Run generation process for all models */
all(models: ExplicitModel[], template: Template): string | Promise<string>;
}
export interface GeneratorResult {
/** The file path */
path: string;
/** The file content */
content: string;
}
export declare type SingleModelGenerationContext = {
m: ExplicitModel;
model: ExplicitModel;
};
export declare type MultipleModelsGenerationContext = {
m: ExplicitModel[];
models: ExplicitModel[];
};
export declare type GenerationContext = SingleModelGenerationContext | MultipleModelsGenerationContext;
export interface NumberedError extends Error {
code: number;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Interfaces.js.map
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../src/Interfaces.ts"],"names":[],"mappings":""}
import { StringVariations } from './Interfaces';
/** Convert a string to camel case, pascal case, etc... */
export declare function StringVariants(value: string): StringVariations;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringVariants = void 0;
const Case = __importStar(require("case"));
/** Convert a string to camel case, pascal case, etc... */
function StringVariants(value) {
return {
raw: value,
kebab: Case.kebab(value),
snake: Case.snake(value),
header: Case.header(value),
constant: Case.constant(value),
big: Case.constant(value).replace(/_/g, '-'),
capital: Case.capital(value),
lower: Case.lower(value),
upper: Case.upper(value),
compact: Case.snake(value).replace(/_/g, ''),
pascal: Case.pascal(value),
camel: Case.camel(value),
};
}
exports.StringVariants = StringVariants;
//# sourceMappingURL=StringVariants.js.map
{"version":3,"file":"StringVariants.js","sourceRoot":"","sources":["../src/StringVariants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAI7B,0DAA0D;AAC1D,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO;QACL,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC9B,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;QAC5C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC5B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KACzB,CAAC;AACJ,CAAC;AAfD,wCAeC"}

Sorry, the diff of this file is not supported yet

+4
-2

@@ -1,3 +0,5 @@

import { Generator as Service } from './generators/generator';
export * from './errors';
import { Generator as Service } from './generators/Generator';
export declare const Generator: Service;
export { InternalError } from './errors/InternalError';
export { TimeoutError } from './errors/TimeoutError';
export { EvaluationError } from './errors/EvaluationError';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Generator = void 0;
const generator_1 = require("./generators/generator");
__exportStar(require("./errors"), exports);
exports.Generator = new generator_1.Generator();
exports.EvaluationError = exports.TimeoutError = exports.InternalError = exports.Generator = void 0;
const Generator_1 = require("./generators/Generator");
exports.Generator = new Generator_1.Generator();
var InternalError_1 = require("./errors/InternalError");
Object.defineProperty(exports, "InternalError", { enumerable: true, get: function () { return InternalError_1.InternalError; } });
var TimeoutError_1 = require("./errors/TimeoutError");
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return TimeoutError_1.TimeoutError; } });
var EvaluationError_1 = require("./errors/EvaluationError");
Object.defineProperty(exports, "EvaluationError", { enumerable: true, get: function () { return EvaluationError_1.EvaluationError; } });
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAA8D;AAE9D,2CAAyB;AACZ,QAAA,SAAS,GAAG,IAAI,qBAAO,EAAE,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAA8D;AAEjD,QAAA,SAAS,GAAG,IAAI,qBAAO,EAAE,CAAC;AACvC,wDAAuD;AAA9C,8GAAA,aAAa,OAAA;AACtB,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AACrB,4DAA2D;AAAlD,kHAAA,eAAe,OAAA"}
{
"name": "@hapify/generator",
"version": "0.8.0",
"version": "1.0.0",
"description": "Generator for Hapify templates",
"keywords": [
"hapify",
"generator"
],
"license": "MIT",
"author": "Edouard Demotes-Mainard <edouard@tractr.net>",
"homepage": "https://github.com/hapify/hapify",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"update": "npm-check -u",
"build": "rimraf dist && tsc -p .",
"clean": "rimraf dist node_modules coverage .nyc_output",
"prepublishOnly": "npm run build",
"lint": "npm run lint:tsc && npm run lint:prettier && npm run lint:eslint",
"lint:eslint": "eslint \"{src,test}/**/*.{ts,js}\"",
"lint:eslint:fix": "npm run lint:eslint -- --fix",
"lint:fix": "npm run lint:tsc:fix && npm run lint:prettier:fix && npm run lint:eslint:fix",
"lint:prettier": "prettier --check \"{src,test}/**/*.{ts,js}\"",
"lint:prettier:fix": "prettier --write \"{src,test}/**/*.{ts,js}\"",
"lint:tsc": "tsc --noEmit",
"lint:tsc:fix": "npm run lint:tsc",
"test": "nyc mocha",
"lint": "prettier --write '**/*.ts'",
"build": "rimraf dist && tsc -p ."
"update": "npm-check -u"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:hapify/generator.git"
},
"keywords": [
"hapify",
"generator"
],
"author": "Edouard Demotes-Mainard <edouard@tractr.net>",
"license": "MIT",
"homepage": "https://github.com/hapify/generator#readme",
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@hapi/code": "^8.0.2",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.22",
"husky": "^4.3.8",
"mocha": "^8.2.1",
"npm-check": "^5.9.2",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
"mocha": "^8.2.1"
},
"dependencies": {
"@hapify/ejs": "^0.4.1",
"@hapify/syntax": "^0.9.0",
"@hapify/vm": "^0.3.6",
"@hapify/ejs": "1.1.0",
"@hapify/syntax": "1.1.0",
"@hapify/vm": "1.2.0",
"case": "^1.6.3"

@@ -48,9 +42,3 @@ },

"node": ">=9"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "pretty-quick --staged --pattern \"**/*.ts\""
}
}
}
export declare const Config: {
Generator: {
timeout: number;
};
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
exports.Config = {
Generator: {
timeout: 1000,
},
};
//# sourceMappingURL=config.js.map
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACrB,SAAS,EAAE;QACV,OAAO,EAAE,IAAI;KACb;CACD,CAAC"}
import { NumberedError } from './interfaces';
export declare class InternalError extends Error implements NumberedError {
code: number;
name: string;
}
export declare class EvaluationError extends Error implements NumberedError {
code: number;
name: string;
lineNumber: number;
columnNumber: number;
details: string;
}
export declare class TimeoutError extends Error implements NumberedError {
code: number;
name: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeoutError = exports.EvaluationError = exports.InternalError = void 0;
class InternalError extends Error {
constructor() {
super(...arguments);
this.code = 2001;
this.name = 'GeneratorInternalError';
}
}
exports.InternalError = InternalError;
class EvaluationError extends Error {
constructor() {
super(...arguments);
this.code = 2004;
this.name = 'GeneratorEvaluationError';
this.lineNumber = null;
this.columnNumber = null;
this.details = null;
}
}
exports.EvaluationError = EvaluationError;
class TimeoutError extends Error {
constructor() {
super(...arguments);
this.code = 2005;
this.name = 'GeneratorTimeoutError';
}
}
exports.TimeoutError = TimeoutError;
//# sourceMappingURL=errors.js.map
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAc,SAAQ,KAAK;IAAxC;;QACC,SAAI,GAAG,IAAI,CAAC;QACZ,SAAI,GAAG,wBAAwB,CAAC;IACjC,CAAC;CAAA;AAHD,sCAGC;AACD,MAAa,eAAgB,SAAQ,KAAK;IAA1C;;QACC,SAAI,GAAG,IAAI,CAAC;QACZ,SAAI,GAAG,0BAA0B,CAAC;QAClC,eAAU,GAAW,IAAI,CAAC;QAC1B,iBAAY,GAAW,IAAI,CAAC;QAC5B,YAAO,GAAW,IAAI,CAAC;IACxB,CAAC;CAAA;AAND,0CAMC;AACD,MAAa,YAAa,SAAQ,KAAK;IAAvC;;QACC,SAAI,GAAG,IAAI,CAAC;QACZ,SAAI,GAAG,uBAAuB,CAAC;IAChC,CAAC;CAAA;AAHD,oCAGC"}
import { GeneratorResult, Model, Template } from '../interfaces';
export declare class Generator {
/** Available generators */
private generators;
constructor();
/**
* Run generation process for one model
* "forIds": A list of models ids to restrict generation to
* Throws an error if the template needs a model and no model is passed
*/
run(templates: Template[], models: Model[], forIds?: string[]): Promise<GeneratorResult[]>;
/** Only process the path */
path(path: string, modelName?: string): string;
/** Ensure error has a code and returns it */
private formatError;
/** Get generator instance from template.engine */
private getGeneratorForTemplate;
/**
* Run generation process for one model and one template
* Throws an error if the template rendering engine is unknown
*/
private one;
/**
* Run generation process for all models and one template
* Throws an error if the template rendering engine is unknown
*/
private all;
/** Convert the model to an object containing all its properties */
private explicitModel;
/** Convert the model to an object containing all its properties unless references and dependencies */
private explicitDeepModel;
/** Convert the model used for a reference. Get model description (first level) and remove non referencing fields */
private explicitReferenceModel;
/** Return all dependent models as deep models */
private explicitDependencies;
/** Map entity fields to target models */
private explicitReferences;
/** Get models using this model */
private explicitReferencedIn;
/** Extract and process fields from model */
private explicitFields;
/** Extract and process accesses from model */
private explicitAccesses;
/** Compute models properties from fields */
private explicitProperties;
/** Convert all the models to an array of objects containing all its properties */
private explicitAllModels;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Generator = void 0;
const string_1 = require("../string");
const hpf_generator_1 = require("./workers/hpf-generator");
const javascript_generator_1 = require("./workers/javascript-generator");
const ejs_generator_1 = require("./workers/ejs-generator");
const errors_1 = require("../errors");
const CACHE_ENABLED = true;
class Generator {
constructor() {
/** Available generators */
this.generators = {
hpf: new hpf_generator_1.HpfGenerator(),
js: new javascript_generator_1.JavascriptGenerator(),
ejs: new ejs_generator_1.EJSGenerator(),
};
}
/**
* Run generation process for one model
* "forIds": A list of models ids to restrict generation to
* Throws an error if the template needs a model and no model is passed
*/
run(templates, models, forIds) {
return __awaiter(this, void 0, void 0, function* () {
try {
// Create results stack
const output = [];
// Create a new cache context
const cache = {};
// For each template, run sub process
for (const template of templates) {
if (template.input === 'one') {
for (const model of models) {
if (forIds && !forIds.find((id) => id === model.id)) {
continue;
}
output.push(yield this.one(template, models, model, cache));
}
}
else {
output.push(yield this.all(template, models, cache));
}
}
return output;
}
catch (error) {
throw this.formatError(error);
}
});
}
/** Only process the path */
path(path, modelName) {
try {
// Quick exit
if (!modelName) {
return path;
}
const variants = string_1.StringVariants(modelName);
const keys = Object.keys(variants);
for (const key of keys) {
path = path.replace(new RegExp(`{${key}}`, 'g'), variants[key]);
}
return path;
}
catch (error) {
throw this.formatError(error);
}
}
/** Ensure error has a code and returns it */
formatError(error) {
// Error is already formatted ?
if (typeof error.code === 'undefined') {
const newError = new errors_1.InternalError(error.message);
newError.stack = error.stack;
return newError;
}
return error;
}
/** Get generator instance from template.engine */
getGeneratorForTemplate(template) {
if (typeof this.generators[template.engine] === 'undefined') {
throw new Error(`Unknown engine ${template.engine}`);
}
return this.generators[template.engine];
}
/**
* Run generation process for one model and one template
* Throws an error if the template rendering engine is unknown
*/
one(template, models, model, cache) {
return __awaiter(this, void 0, void 0, function* () {
// Compute path
const path = this.path(template.path, model.name);
// Get full model description
const input = this.explicitModel(models, model, cache);
// Compute content
const generator = this.getGeneratorForTemplate(template);
const content = yield generator.one(input, template);
return {
content,
path,
};
});
}
/**
* Run generation process for all models and one template
* Throws an error if the template rendering engine is unknown
*/
all(template, models, cache) {
return __awaiter(this, void 0, void 0, function* () {
// Compute path
const path = this.path(template.path);
// Get full models description
const input = this.explicitAllModels(models, cache);
// Compute content
const generator = this.getGeneratorForTemplate(template);
const content = yield generator.all(input, template);
return {
content,
path,
};
});
}
/** Convert the model to an object containing all its properties */
explicitModel(models, model, cache, depth = 0) {
// Return cache value if any
if (CACHE_ENABLED && depth === 0 && cache[model.id]) {
return cache[model.id];
}
const deepFields = this.explicitFields(model);
const accesses = this.explicitAccesses(model);
const references = this.explicitReferences(models, deepFields.list);
const fields = Object.assign(deepFields, {
references,
r: references,
});
const dependencies = this.explicitDependencies(model, fields.references);
const referencedIn = this.explicitReferencedIn(models, model);
const properties = Object.assign(this.explicitProperties(deepFields), {
hasDependencies: dependencies.list.length > 0,
isReferenced: referencedIn.length > 0,
});
// Create explicit model
const m = {
id: model.id,
name: model.name,
names: string_1.StringVariants(model.name),
fields,
f: fields,
properties,
p: properties,
accesses,
a: accesses,
dependencies,
d: dependencies,
referencedIn,
ri: referencedIn,
};
// Store cache
if (CACHE_ENABLED && depth === 0) {
cache[model.id] = m;
}
return m;
}
/** Convert the model to an object containing all its properties unless references and dependencies */
explicitDeepModel(model) {
const fields = this.explicitFields(model);
const properties = this.explicitProperties(fields);
const accesses = this.explicitAccesses(model);
return {
id: model.id,
name: model.name,
names: string_1.StringVariants(model.name),
fields,
f: fields,
properties,
p: properties,
accesses,
a: accesses,
};
}
/** Convert the model used for a reference. Get model description (first level) and remove non referencing fields */
explicitReferenceModel(model, filter) {
const fields = this.explicitFields(model);
const properties = this.explicitProperties(fields);
const accesses = this.explicitAccesses(model);
const filteredFields = fields.list.filter(filter);
filteredFields.f = filteredFields.filter;
return {
id: model.id,
name: model.name,
names: string_1.StringVariants(model.name),
fields: filteredFields,
f: filteredFields,
properties,
p: properties,
accesses,
a: accesses,
};
}
/** Return all dependent models as deep models */
explicitDependencies(model, references) {
// Create method to reduce references to dependencies
// A custom filter can be passed
// If the second argument is false, keep the self dependency
const dependencies = (filter = (f) => !!f, excludeSelf = true) => {
const duplicates = {};
return (references
// Apply custom filter
.filter(filter)
// Remove self
.filter((ref) => (excludeSelf ? ref.model.id !== model.id : true))
// Remove duplicates
.filter((ref) => {
if (duplicates[ref.value] === true) {
return false;
}
duplicates[ref.value] = true;
return true;
})
// Extract models
.map((ref) => ref.model));
};
// A boolean to determine if the model has a self dependency
const selfDependency = references.some((ref) => ref.model.id === model.id);
const allDependencies = dependencies();
return {
list: allDependencies,
l: allDependencies,
filter: dependencies,
f: dependencies,
self: selfDependency,
s: selfDependency,
};
}
/** Map entity fields to target models */
explicitReferences(models, fields) {
// Get reference fields
// Then explicit the reference. If no reference is found returns null (it will be filtered after)
const references = fields
.filter((f) => f.type === 'entity' && f.value)
.map((field) => {
const reference = models.find((m) => m.id === field.value);
// Nothing found
if (!reference) {
return null;
}
// Add reference to object
const subField = this.explicitDeepModel(reference);
field.model = subField;
field.m = subField;
return field;
})
.filter((f) => !!f);
// Add filter alias
references.f = references.filter;
return references;
}
/** Get models using this model */
explicitReferencedIn(models, model) {
// Filter referencing models
const extractReferencingFields = (f) => f.type === 'entity' && f.value === model.id;
const referencedIn = models
.filter((m) => m.fields.some(extractReferencingFields))
.map((m) => this.explicitReferenceModel(m, extractReferencingFields));
referencedIn.f = referencedIn.filter;
return referencedIn;
}
/** Extract and process fields from model */
explicitFields(model) {
// Get and format fields
const fields = model.fields.map((f) => {
const explicitField = Object.assign({
names: string_1.StringVariants(f.name),
}, f);
// Deal with enums
if (f.type === 'enum' && f.value) {
const enumValues = f.value.map((v) => ({
name: v,
names: string_1.StringVariants(v),
}));
enumValues.f = enumValues.filter;
explicitField.enum = enumValues;
explicitField.e = enumValues;
}
return explicitField;
});
// Create explicit field groups
const primary = fields.find((f) => f.primary);
const unique = fields.filter((f) => f.unique);
const label = fields.filter((f) => f.label);
const searchableLabel = fields.filter((f) => f.label && f.searchable);
const nullable = fields.filter((f) => f.nullable);
const multiple = fields.filter((f) => f.multiple);
const embedded = fields.filter((f) => f.embedded);
const searchable = fields.filter((f) => f.searchable);
const sortable = fields.filter((f) => f.sortable);
const hidden = fields.filter((f) => f.hidden);
const internal = fields.filter((f) => f.internal);
const restricted = fields.filter((f) => f.restricted);
const ownership = fields.filter((f) => f.ownership);
// Create filter function
const filter = (callback = null) => {
return typeof callback === 'function' ? fields.filter(callback) : fields;
};
return {
list: fields,
l: fields,
filter,
f: filter,
primary,
pr: primary,
unique,
un: unique,
label,
lb: label,
nullable,
nu: nullable,
multiple,
ml: multiple,
embedded,
em: embedded,
searchable,
se: searchable,
sortable,
so: sortable,
hidden,
hd: hidden,
internal,
in: internal,
restricted,
rs: restricted,
ownership,
os: ownership,
searchableLabel,
sl: searchableLabel,
};
}
/** Extract and process accesses from model */
explicitAccesses(model) {
// Compute accesses sub-object for each action
// For each action, add a boolean for each access that denote if the access type is granted
const accesses = [];
const ordered = ['admin', 'owner', 'auth', 'guest'];
const indexes = {
admin: ordered.indexOf('admin'),
owner: ordered.indexOf('owner'),
auth: ordered.indexOf('auth'),
guest: ordered.indexOf('guest'),
};
const actions = Object.keys(model.accesses);
for (const action of actions) {
const accessIndex = ordered.indexOf(model.accesses[action]);
const description = {
action: action,
admin: accessIndex === indexes.admin,
owner: accessIndex === indexes.owner,
auth: accessIndex === indexes.auth,
guest: accessIndex === indexes.guest,
gteAdmin: accessIndex >= indexes.admin,
gteOwner: accessIndex >= indexes.owner,
gteAuth: accessIndex >= indexes.auth,
gteGuest: accessIndex >= indexes.guest,
lteAdmin: accessIndex <= indexes.admin,
lteOwner: accessIndex <= indexes.owner,
lteAuth: accessIndex <= indexes.auth,
lteGuest: accessIndex <= indexes.guest,
};
accesses.push(description);
}
// Get admin actions
const admin = accesses.filter((a) => a.admin);
// Get owner actions
const owner = accesses.filter((a) => a.owner);
// Get auth actions
const auth = accesses.filter((a) => a.auth);
// Get guest actions
const guest = accesses.filter((a) => a.guest);
// Get actions
const actionCreate = accesses.find((a) => a.action === 'create');
const actionRead = accesses.find((a) => a.action === 'read');
const actionUpdate = accesses.find((a) => a.action === 'update');
const actionRemove = accesses.find((a) => a.action === 'remove');
const actionSearch = accesses.find((a) => a.action === 'search');
const actionCount = accesses.find((a) => a.action === 'count');
// Pre-computed properties
const accessProperties = {
onlyAdmin: admin.length === accesses.length,
onlyOwner: owner.length === accesses.length,
onlyAuth: auth.length === accesses.length,
onlyGuest: guest.length === accesses.length,
maxAdmin: admin.length > 0 && owner.length === 0 && auth.length === 0 && guest.length === 0,
maxOwner: owner.length > 0 && auth.length === 0 && guest.length === 0,
maxAuth: auth.length > 0 && guest.length === 0,
maxGuest: guest.length > 0,
noAdmin: admin.length === 0,
noOwner: owner.length === 0,
noAuth: auth.length === 0,
noGuest: guest.length === 0,
hasAdmin: admin.length > 0,
hasOwner: owner.length > 0,
hasAuth: auth.length > 0,
hasGuest: guest.length > 0,
};
// Create filter function
const filterAccess = (func = null) => {
return typeof func === 'function' ? accesses.filter(func) : accesses;
};
return {
list: accesses,
l: accesses,
filter: filterAccess,
f: filterAccess,
properties: accessProperties,
p: accessProperties,
// By access
admin,
ad: admin,
owner,
ow: owner,
auth,
au: auth,
guest,
gs: guest,
// By actions
create: actionCreate,
c: actionCreate,
read: actionRead,
r: actionRead,
update: actionUpdate,
u: actionUpdate,
remove: actionRemove,
d: actionRemove,
search: actionSearch,
s: actionSearch,
count: actionCount,
n: actionCount,
};
}
/** Compute models properties from fields */
explicitProperties(fields) {
return {
fieldsCount: fields.list.length,
hasPrimary: !!fields.primary,
hasUnique: fields.unique.length > 0,
hasLabel: fields.label.length > 0,
hasNullable: fields.nullable.length > 0,
hasMultiple: fields.multiple.length > 0,
hasEmbedded: fields.embedded.length > 0,
hasSearchable: fields.searchable.length > 0,
hasSortable: fields.sortable.length > 0,
hasHidden: fields.hidden.length > 0,
hasInternal: fields.internal.length > 0,
hasRestricted: fields.restricted.length > 0,
hasOwnership: fields.ownership.length > 0,
hasSearchableLabel: fields.searchableLabel.length > 0,
mainlyHidden: fields.list.length < 2 * fields.hidden.length,
mainlyInternal: fields.list.length < 2 * fields.internal.length,
isGeolocated: fields.list.filter((f) => f.type === 'number' && f.subtype === 'latitude').length > 0 &&
fields.list.filter((f) => f.type === 'number' && f.subtype === 'longitude').length > 0,
isGeoSearchable: fields.list.filter((f) => f.type === 'number' && f.subtype === 'latitude' && f.searchable).length > 0 &&
fields.list.filter((f) => f.type === 'number' && f.subtype === 'longitude' && f.searchable).length > 0,
};
}
/** Convert all the models to an array of objects containing all its properties */
explicitAllModels(models, cache) {
return models.map((mod) => this.explicitModel(models, mod, cache));
}
}
exports.Generator = Generator;
//# sourceMappingURL=generator.js.map
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/generators/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAA2C;AAC3C,2DAAuD;AACvD,yEAAqE;AACrE,2DAAuD;AA+BvD,sCAA0C;AAO1C,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAa,SAAS;IAQrB;QAPA,2BAA2B;QACnB,eAAU,GAAyC;YAC1D,GAAG,EAAE,IAAI,4BAAY,EAAE;YACvB,EAAE,EAAE,IAAI,0CAAmB,EAAE;YAC7B,GAAG,EAAE,IAAI,4BAAY,EAAE;SACvB,CAAC;IAEa,CAAC;IAEhB;;;;OAIG;IACG,GAAG,CAAC,SAAqB,EAAE,MAAe,EAAE,MAAiB;;YAClE,IAAI;gBACH,uBAAuB;gBACvB,MAAM,MAAM,GAAsB,EAAE,CAAC;gBACrC,6BAA6B;gBAC7B,MAAM,KAAK,GAAU,EAAE,CAAC;gBACxB,qCAAqC;gBACrC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;oBACjC,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,EAAE;wBAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;4BAC3B,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE;gCACpD,SAAS;6BACT;4BACD,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;yBAC5D;qBACD;yBAAM;wBACN,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;qBACrD;iBACD;gBAC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GAAU,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;CACD;AAvfD,8BAufC"}
import { ExplicitModel, GenerationContext, GeneratorWorker, Template } from '../../interfaces';
export declare abstract class BaseGenerator implements GeneratorWorker {
one(model: ExplicitModel, template: Template): Promise<string>;
all(models: ExplicitModel[], template: Template): Promise<string>;
/** Append file name to error details if applicable */
protected appendFileName(error: Error, template: Template): Error;
protected abstract eval(content: string, context: GenerationContext): string;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseGenerator = void 0;
class BaseGenerator {
one(model, template) {
return __awaiter(this, void 0, void 0, function* () {
try {
return this.eval(template.content, {
model: model,
m: model,
});
}
catch (error) {
throw this.appendFileName(error, template);
}
});
}
all(models, template) {
return __awaiter(this, void 0, void 0, function* () {
try {
return this.eval(template.content, {
models: models,
m: models,
});
}
catch (error) {
throw this.appendFileName(error, template);
}
});
}
/** Append file name to error details if applicable */
appendFileName(error, template) {
if (typeof error.lineNumber !== 'undefined') {
// Append file name
error.details += `\nFile: ${template.path}`;
}
return error;
}
}
exports.BaseGenerator = BaseGenerator;
//# sourceMappingURL=base-generator.js.map
{"version":3,"file":"base-generator.js","sourceRoot":"","sources":["../../../src/generators/workers/base-generator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,MAAsB,aAAa;IAC5B,GAAG,CAAC,KAAoB,EAAE,QAAkB;;YACjD,IAAI;gBACH,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;oBAClC,KAAK,EAAE,KAAK;oBACZ,CAAC,EAAE,KAAK;iBACR,CAAC,CAAC;aACH;YAAC,OAAO,KAAK,EAAE;gBACf,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;aAC3C;QACF,CAAC;KAAA;IAEK,GAAG,CAAC,MAAuB,EAAE,QAAkB;;YACpD,IAAI;gBACH,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;oBAClC,MAAM,EAAE,MAAM;oBACd,CAAC,EAAE,MAAM;iBACT,CAAC,CAAC;aACH;YAAC,OAAO,KAAK,EAAE;gBACf,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;aAC3C;QACF,CAAC;KAAA;IAED,sDAAsD;IAC5C,cAAc,CAAC,KAAY,EAAE,QAAkB;QACxD,IAAI,OAAyB,KAAM,CAAC,UAAU,KAAK,WAAW,EAAE;YAC/D,mBAAmB;YACD,KAAM,CAAC,OAAO,IAAI,WAAW,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC/D;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CAGD;AAjCD,sCAiCC"}
import { GenerationContext } from '../../interfaces';
import { BaseGenerator } from './base-generator';
export declare class EJSGenerator extends BaseGenerator {
protected eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EJSGenerator = void 0;
const config_1 = require("../../config");
const ejs_1 = require("@hapify/ejs");
const base_generator_1 = require("./base-generator");
const HpfOptions = { timeout: config_1.Config.Generator.timeout };
class EJSGenerator extends base_generator_1.BaseGenerator {
eval(content, context) {
return new ejs_1.HapifyEJS(HpfOptions).run(content, context);
}
}
exports.EJSGenerator = EJSGenerator;
//# sourceMappingURL=ejs-generator.js.map
{"version":3,"file":"ejs-generator.js","sourceRoot":"","sources":["../../../src/generators/workers/ejs-generator.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAEtC,qCAAwC;AACxC,qDAAiD;AAEjD,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,eAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;AAEzD,MAAa,YAAa,SAAQ,8BAAa;IACpC,IAAI,CAAC,OAAe,EAAE,OAA0B;QACzD,OAAO,IAAI,eAAS,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACD;AAJD,oCAIC"}
import { GenerationContext } from '../../interfaces';
import { BaseGenerator } from './base-generator';
export declare class HpfGenerator extends BaseGenerator {
protected eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HpfGenerator = void 0;
const syntax_1 = require("@hapify/syntax");
const config_1 = require("../../config");
const base_generator_1 = require("./base-generator");
const HpfOptions = { timeout: config_1.Config.Generator.timeout };
class HpfGenerator extends base_generator_1.BaseGenerator {
eval(content, context) {
return syntax_1.HapifySyntax.run(content, context.m, HpfOptions);
}
}
exports.HpfGenerator = HpfGenerator;
//# sourceMappingURL=hpf-generator.js.map
{"version":3,"file":"hpf-generator.js","sourceRoot":"","sources":["../../../src/generators/workers/hpf-generator.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAC9C,yCAAsC;AAEtC,qDAAiD;AAEjD,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,eAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;AAEzD,MAAa,YAAa,SAAQ,8BAAa;IACpC,IAAI,CAAC,OAAe,EAAE,OAA0B;QACzD,OAAO,qBAAY,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;CACD;AAJD,oCAIC"}
import { GenerationContext } from '../../interfaces';
import { BaseGenerator } from './base-generator';
export declare class JavascriptGenerator extends BaseGenerator {
protected eval(content: string, context: GenerationContext): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JavascriptGenerator = void 0;
const vm_1 = require("@hapify/vm");
const config_1 = require("../../config");
const errors_1 = require("../../errors");
const base_generator_1 = require("./base-generator");
class JavascriptGenerator extends base_generator_1.BaseGenerator {
eval(content, context) {
try {
return new vm_1.HapifyVM({ timeout: config_1.Config.Generator.timeout }).run(content, context);
}
catch (error) {
if (error.code === 6003) {
throw new errors_1.TimeoutError(`Template processing timed out (${config_1.Config.Generator.timeout}ms)`);
}
if (error.code === 6002) {
// Clone error
const evalError = new errors_1.EvaluationError(error.message);
evalError.details = `Error: ${evalError.message}. Line: ${error.lineNumber}, Column: ${error.columnNumber}`;
evalError.lineNumber = error.lineNumber;
evalError.columnNumber = error.columnNumber;
throw evalError;
}
throw error;
}
}
}
exports.JavascriptGenerator = JavascriptGenerator;
//# sourceMappingURL=javascript-generator.js.map
{"version":3,"file":"javascript-generator.js","sourceRoot":"","sources":["../../../src/generators/workers/javascript-generator.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,yCAAsC;AAEtC,yCAA6D;AAC7D,qDAAiD;AAEjD,MAAa,mBAAoB,SAAQ,8BAAa;IAC3C,IAAI,CAAC,OAAe,EAAE,OAA0B;QACzD,IAAI;YACH,OAAO,IAAI,aAAQ,CAAC,EAAE,OAAO,EAAE,eAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACjF;QAAC,OAAO,KAAK,EAAE;YACf,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,qBAAY,CAAC,kCAAkC,eAAM,CAAC,SAAS,CAAC,OAAO,KAAK,CAAC,CAAC;aACxF;YACD,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;gBACxB,cAAc;gBACd,MAAM,SAAS,GAAG,IAAI,wBAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACrD,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,CAAC,OAAO,WAAW,KAAK,CAAC,UAAU,aAAa,KAAK,CAAC,YAAY,EAAE,CAAC;gBAC5G,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;gBACxC,SAAS,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;gBAC5C,MAAM,SAAS,CAAC;aAChB;YACD,MAAM,KAAK,CAAC;SACZ;IACF,CAAC;CACD;AAnBD,kDAmBC"}
export interface NameInterpolable {
/** The name of the object, as the user entered it */
name: string;
/** All names computed from the `name` property */
names: StringVariations;
}
export declare type FieldType = 'boolean' | 'number' | 'string' | 'enum' | 'datetime' | 'entity' | 'object' | 'file';
export declare type FieldSubType = 'integer' | 'float' | 'latitude' | 'longitude' | 'email' | 'password' | 'url' | 'text' | 'rich' | 'date' | 'time' | 'image' | 'video' | 'audio' | 'document' | 'oneOne' | 'oneMany' | 'manyOne' | 'manyMany';
export declare type FieldValueType<T> = T extends 'entity' ? string : T extends 'enum' ? string[] : null;
export interface Field<T extends FieldType = FieldType> {
/** The field's name */
name: string;
/** The field's type */
type: T;
/** The field's subtype */
subtype: FieldSubType | null;
/**
* Value of the fields. Used if the type is entity or enum.
* - Entity: The UUID string of the targeted model
* - Enum: list of enum values
*/
value: FieldValueType<T>;
/** Should be used as a primary key or not */
primary: boolean;
/** Should be used as a unique key or not */
unique: boolean;
/** Should be used as a label or not */
label: boolean;
/** Denotes if the field can be empty or not */
nullable: boolean;
/** Denotes if the field is an array of values */
multiple: boolean;
/** Indicate whether the field is embedded (should be always exposed explicitly) */
embedded: boolean;
/** Indicate whether the field is searchable or not */
searchable: boolean;
/** Indicate whether the field is sortable or not */
sortable: boolean;
/** Indicate whether the field is hidden (should not be exposed) */
hidden: boolean;
/** Indicate whether the field is for an internal use only (should not be defined by an user) */
internal: boolean;
/** Indicate whether the field is restricted to authorized roles (should only be defined by an admin) */
restricted: boolean;
/** Indicate that this field defines the owner of the entity */
ownership: boolean;
}
/**
* Possible values for actions' access:
* - admin (Denotes if the access is restricted to the admins)
* - owner (Denotes if the access is restricted to the owner of the resource)
* - authenticated (Denotes if the access is restricted to authenticated users)
* - guest (Denotes if the access is not restricted)
*/
export declare type Access = 'admin' | 'owner' | 'auth' | 'guest';
/** Define the access for each available action */
export interface Accesses {
create: Access;
read: Access;
update: Access;
remove: Access;
search: Access;
count: Access;
}
/** Possible actions */
export declare type Action = keyof Accesses;
export interface Model {
/** The model's unique id */
id: string;
/** The model's name */
name: string;
/** The fields of the model */
fields: Field[];
/** The model privacy access */
accesses: Accesses;
}
export declare type Engine = 'hpf' | 'js' | 'ejs';
export declare type Input = 'one' | 'all';
export interface Template {
/** The template's path */
path: string;
/** The template's type */
engine: Engine;
/** Denotes if the template has to to be ran for one or all models */
input: Input;
/** The template's content */
content: string;
}
export interface AliasedArray<T> extends Array<T> {
/** Alias of `filter` */
f(callback: (value: T, index: number, array: T[]) => value is T, thisArg?: any): T[];
}
interface BaseExplicitModel extends NameInterpolable {
/** An unique id */
id: string;
/** An object containing pre-computed properties from fields */
properties: ExplicitDeepModelProperties;
/** Alias of `p` */
p: ExplicitDeepModelProperties;
/** An object containing all action's accesses grouped by action or restriction */
accesses: ExplicitModelAccesses;
/** Alias of `accesses` */
a: ExplicitModelAccesses;
}
export interface ExplicitModel extends BaseExplicitModel {
/** An object containing all fields, grouped in different arrays */
fields: ExplicitModelFields;
/** Alias of `fields` */
f: ExplicitModelFields;
/** An object containing pre-computed properties from fields */
properties: ExplicitModelProperties;
/** Alias of `p` */
p: ExplicitModelProperties;
/** Non-deep model only. An object containing dependencies (to other models) of this model. A model has a dependency if one of this field is of type `entity` */
dependencies: ExplicitModelDependencies;
/** Alias of `dependencies` */
d: ExplicitModelDependencies;
/** Non-deep model only. An array containing models that refer to this one. These models are added as "deep models" */
referencedIn: AliasedArray<ExplicitReferenceModel>;
/** Alias of `referencedIn` */
ri: AliasedArray<ExplicitReferenceModel>;
}
export interface ExplicitDeepModel extends BaseExplicitModel {
/** An object containing all fields, grouped in different arrays */
fields: ExplicitDeepModelFields;
/** Alias of `fields` */
f: ExplicitDeepModelFields;
}
export interface ExplicitReferenceModel extends BaseExplicitModel {
/** An array containing fields referencing the parent the model */
fields: AliasedArray<ExplicitField>;
/** Alias of `fields` */
f: AliasedArray<ExplicitField>;
}
export interface ExplicitEnum extends NameInterpolable {
}
export interface ExplicitField<T extends FieldType = FieldType> extends Field<T>, NameInterpolable {
}
export interface ExplicitReferenceField extends ExplicitField<'entity'> {
/** The target model object if the field is of type `entity` */
model: ExplicitDeepModel;
/** Alias of `model` */
m: ExplicitDeepModel;
}
export interface ExplicitEnumField extends ExplicitField<'enum'> {
/** The list of string variations for the enum */
enum: AliasedArray<ExplicitEnum>;
/** Alias of `enum` */
e: AliasedArray<ExplicitEnum>;
}
export interface ExplicitDeepModelFields {
/** An array containing all fields of the model */
list: ExplicitField[];
/** Alias of `list` */
l: ExplicitField[];
/** The primary field of the model. `null` if no primary field is defined. */
primary: ExplicitField | undefined;
/** Alias of `primary` */
pr: ExplicitField | undefined;
/** An array containing all fields flagged as `unique` */
unique: ExplicitField[];
/** Alias of `unique` */
un: ExplicitField[];
/** An array containing all fields flagged as `label` */
label: ExplicitField[];
/** Alias of `label` */
lb: ExplicitField[];
/** An array containing all fields flagged as `nullable` */
nullable: ExplicitField[];
/** Alias of `nullable` */
nu: ExplicitField[];
/** An array containing all fields flagged as `multiple` */
multiple: ExplicitField[];
/** Alias of `multiple` */
ml: ExplicitField[];
/** An array containing all fields flagged as `embedded` */
embedded: ExplicitField[];
/** Alias of `embedded` */
em: ExplicitField[];
/** An array containing all fields flagged as `searchable` */
searchable: ExplicitField[];
/** Alias of `searchable` */
se: ExplicitField[];
/** An array containing all fields flagged as `sortable` */
sortable: ExplicitField[];
/** Alias of `sortable` */
so: ExplicitField[];
/** An array containing all fields flagged as `hidden` */
hidden: ExplicitField[];
/** Alias of `hidden` */
hd: ExplicitField[];
/** An array containing all fields flagged as `internal` */
internal: ExplicitField[];
/** Alias of `internal` */
in: ExplicitField[];
/** An array containing all fields flagged as `restricted` */
restricted: ExplicitField[];
/** Alias of `restricted` */
rs: ExplicitField[];
/** An array containing all fields flagged as `ownership` */
ownership: ExplicitField[];
/** Alias of `ownership` */
os: ExplicitField[];
/** An array containing all fields flagged as `label` and `searchable`. Useful for quick-search by label. */
searchableLabel: ExplicitField[];
/** Alias of `searchableLabel` */
sl: ExplicitField[];
/** A function for filtering fields with a custom rule. Equivalent of `model.fields.list.filter` */
filter: ExplicitFieldsFilterFunction;
/** Alias of `filter` */
f: ExplicitFieldsFilterFunction;
}
export interface ExplicitModelFields extends ExplicitDeepModelFields {
/** Non-deep model only. An array containing all fields of type `entity`. */
references: AliasedArray<ExplicitReferenceField>;
/** Alias of `references` */
r: AliasedArray<ExplicitReferenceField>;
}
export declare type ExplicitFieldsFilterFunction = (callback: ((value: ExplicitField, index: number, array: ExplicitField[]) => boolean) | null) => ExplicitField[];
export interface ExplicitModelDependencies {
/** An array containing all dependency models, but self. These models are added as "deep models" */
list: ExplicitDeepModel[];
/** Alias of `list` */
l: ExplicitDeepModel[];
/** A boolean indicating if this model has a self-dependency */
self: boolean;
/** Alias of `self` */
s: boolean;
/** A function to filter dependencies */
filter: ExplicitModelDependenciesFilter;
/** Alias of `filter` */
f: ExplicitModelDependenciesFilter;
}
/**
* First argument (function - default `(f) => !!f`): The filtering function receiving the referencer field (the entity field)
* Second argument (boolean - default `true`): A boolean indicating if we should exclude the self dependency.
*/
export declare type ExplicitModelDependenciesFilter = (filter?: (field: ExplicitField) => boolean, excludeSelf?: boolean) => ExplicitDeepModel[];
export interface ExplicitDeepModelProperties {
/** The number of fields contained in the model */
fieldsCount: number;
/** Denotes if the model has a primary field */
hasPrimary: boolean;
/** Denotes if the model has at least one unique field */
hasUnique: boolean;
/** Denotes if the model has at least one label field */
hasLabel: boolean;
/** Denotes if the model has at least one nullable field */
hasNullable: boolean;
/** Denotes if the model has at least one multiple field */
hasMultiple: boolean;
/** Denotes if the model has at least one embedded field */
hasEmbedded: boolean;
/** Denotes if the model has at least one searchable field */
hasSearchable: boolean;
/** Denotes if the model has at least one sortable field */
hasSortable: boolean;
/** Denotes if the model has at least one hidden field */
hasHidden: boolean;
/** Denotes if the model has at least one internal field */
hasInternal: boolean;
/** Denotes if the model has at least one restricted field */
hasRestricted: boolean;
/** Denotes if the model has at least one ownership field */
hasOwnership: boolean;
/** Denotes if the model has at least one field marked as label and also searchable */
hasSearchableLabel: boolean;
/** Denotes if most of the fields are hidden (strictly) */
mainlyHidden: boolean;
/** Denotes if most of the fields are internal (strictly) */
mainlyInternal: boolean;
/** Denotes if the model contains at least one latitude field and one longitude field */
isGeolocated: boolean;
/** Denotes if the model contains at least one searchable latitude field and one searchable longitude field */
isGeoSearchable: boolean;
}
export interface ExplicitModelProperties extends ExplicitDeepModelProperties {
/** Denotes if the model has dependencies to other models or itself (through an `entity` field) */
hasDependencies: boolean;
/** Denotes if the model is referenced by other models */
isReferenced: boolean;
}
export interface ExplicitAccesses {
/** The name of the action */
action: Action;
/** Indicates if the selected access is `admin` */
admin: boolean;
/** Indicates if the selected access is `owner` */
owner: boolean;
/** Indicates if the selected access is `authenticated` */
auth: boolean;
/** Indicates if the selected access is `guest` */
guest: boolean;
/** Denotes if the selected access is greater or equal than `admin` (should always be `true`) */
gteAdmin: boolean;
/** Denotes if the selected access is greater or equal than `owner` */
gteOwner: boolean;
/** Denotes if the selected access is greater or equal than `authenticated` */
gteAuth: boolean;
/** Denotes if the selected access is greater or equal than `guest` */
gteGuest: boolean;
/** Denotes if the selected access is less or equal than `admin` */
lteAdmin: boolean;
/** Denotes if the selected access is less or equal than `owner` */
lteOwner: boolean;
/** Denotes if the selected access is less or equal than `authenticated` */
lteAuth: boolean;
/** Denotes if the selected access is less or equal than `guest` (should always be `true`) */
lteGuest: boolean;
}
export interface ExplicitModelAccessProperties {
/** Denotes if the model only contains actions restricted to `admin` */
onlyAdmin: boolean;
/** Denotes if the model only contains actions restricted to `owner` */
onlyOwner: boolean;
/** Denotes if the model only contains actions restricted to `authenticated` */
onlyAuth: boolean;
/** Denotes if the model only contains actions restricted to `guest` */
onlyGuest: boolean;
/** Denotes if the most permissive access is `admin` */
maxAdmin: boolean;
/** Denotes if the most permissive access is `owner` */
maxOwner: boolean;
/** Denotes if the most permissive access is `authenticated` */
maxAuth: boolean;
/** Denotes if the most permissive access is `guest` */
maxGuest: boolean;
/** Denotes if there is no action restricted to `admin` */
noAdmin: boolean;
/** Denotes if there is no action restricted to `owner` */
noOwner: boolean;
/** Denotes if there is no action restricted to `authenticated` */
noAuth: boolean;
/** Denotes if there is no action restricted to `guest` */
noGuest: boolean;
/** Denotes if there is at least one action restricted to `admin` */
hasAdmin: boolean;
/** Denotes if there is at least one action restricted to `owner` */
hasOwner: boolean;
/** Denotes if there is at least one action restricted to `authenticated` */
hasAuth: boolean;
/** Denotes if there is at least one action restricted to `guest` */
hasGuest: boolean;
}
export declare type ExplicitModelAccessFilter = (func: (a: ExplicitAccesses) => boolean | null) => ExplicitAccesses[];
export interface ExplicitModelAccesses {
/** An array containing all action's accesses of the model. */
list: ExplicitAccesses[];
/** Alias of `list` */
l: ExplicitAccesses[];
/** A function for filtering action's accesses with a custom rule. Equivalent of `model.accesses.list.filter`. */
filter: ExplicitModelAccessFilter;
/** Alias of `filter` */
f: ExplicitModelAccessFilter;
/** An object containing pre-computed properties from action's accesses. */
properties: ExplicitModelAccessProperties;
/** Alias of `properties` */
p: ExplicitModelAccessProperties;
/** An array containing all action's accesses restricted to `admin`. */
admin: ExplicitAccesses[];
/** Alias of `admin` */
ad: ExplicitAccesses[];
/** An array containing all action's accesses restricted to `owner`. */
owner: ExplicitAccesses[];
/** Alias of `owner` */
ow: ExplicitAccesses[];
/** An array containing all action's accesses restricted to `authenticated`. */
auth: ExplicitAccesses[];
/** Alias of `auth` */
au: ExplicitAccesses[];
/** An array containing all action's accesses restricted to `guest`. */
guest: ExplicitAccesses[];
/** Alias of `guest` */
gs: ExplicitAccesses[];
/** An object containing the `create` action's access. */
create: ExplicitAccesses;
/** Alias of `create` */
c: ExplicitAccesses;
/** An object containing the `read` action's access. */
read: ExplicitAccesses;
/** Alias of `read` */
r: ExplicitAccesses;
/** An object containing the `update` action's access. */
update: ExplicitAccesses;
/** Alias of `update` */
u: ExplicitAccesses;
/** An object containing the `delete` action's access. */
remove: ExplicitAccesses;
/** Alias of `remove` */
d: ExplicitAccesses;
/** An object containing the `search` action's access. */
search: ExplicitAccesses;
/** Alias of `search` */
s: ExplicitAccesses;
/** An object containing the `count` action's access. */
count: ExplicitAccesses;
/** Alias of `count` */
n: ExplicitAccesses;
}
export interface StringVariations {
/** The string of the field, as the user entered it. Example `fiRst Name`. */
raw: string;
/** The string with hyphens and lower case. Example `first-name`. */
kebab: string;
/** The string with underscores and lower case. Example `first_name`. */
snake: string;
/** The string with hyphens and first letters capitalized. Example `First-Name`. */
header: string;
/** The string with underscores and upper case. Example `FIRST_NAME`. */
constant: string;
/** The string with hyphens and upper case. Example `FIRST-NAME`. */
big: string;
/** The string as words with upper case on first letters. Example `First Name`. */
capital: string;
/** The string as words in lower case. Example `first name`. */
lower: string;
/** The string as words in upper case. Example `FIRST NAME`. */
upper: string;
/** The string joined and lower case. Example `firstname`. */
compact: string;
/** The string as upper camel case. Example `FirstName`. */
pascal: string;
/** The string as lower camel case. Example `firstName`. */
camel: string;
}
export declare type StringVariationType = keyof StringVariations;
export interface GeneratorWorker {
/** Run generation process for one model */
one(model: ExplicitModel, template: Template): Promise<string>;
/** Run generation process for all models */
all(models: ExplicitModel[], template: Template): Promise<string>;
}
export interface GeneratorResult {
/** The file path */
path: string;
/** The file content */
content: string;
}
export declare type SingleModelGenerationContext = {
m: ExplicitModel;
model: ExplicitModel;
};
export declare type MultipleModelsGenerationContext = {
m: ExplicitModel[];
models: ExplicitModel[];
};
export declare type GenerationContext = SingleModelGenerationContext | MultipleModelsGenerationContext;
export interface NumberedError extends Error {
code: number;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
import { StringVariations } from './interfaces';
/** Convert a string to camel case, pascal case, etc... */
export declare function StringVariants(value: string): StringVariations;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringVariants = void 0;
const Case = __importStar(require("case"));
/** Convert a string to camel case, pascal case, etc... */
function StringVariants(value) {
return {
raw: value,
kebab: Case.kebab(value),
snake: Case.snake(value),
header: Case.header(value),
constant: Case.constant(value),
big: Case.constant(value).replace(/_/g, '-'),
capital: Case.capital(value),
lower: Case.lower(value),
upper: Case.upper(value),
compact: Case.snake(value).replace(/_/g, ''),
pascal: Case.pascal(value),
camel: Case.camel(value),
};
}
exports.StringVariants = StringVariants;
//# sourceMappingURL=string.js.map
{"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,0DAA0D;AAC1D,SAAgB,cAAc,CAAC,KAAa;IAC3C,OAAO;QACN,GAAG,EAAE,KAAK;QACV,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC9B,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;QAC5C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC5B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KACxB,CAAC;AACH,CAAC;AAfD,wCAeC"}