@statezero/core 0.1.73 → 0.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/actions/django_app/calculate-hash.d.ts +57 -0
  2. package/dist/actions/django_app/calculate-hash.js +77 -0
  3. package/dist/actions/django_app/get-current-username.d.ts +29 -0
  4. package/dist/actions/django_app/get-current-username.js +62 -0
  5. package/dist/actions/django_app/get-server-status.d.ts +38 -0
  6. package/dist/actions/django_app/get-server-status.js +65 -0
  7. package/dist/actions/django_app/get-user-info.d.ts +44 -0
  8. package/dist/actions/django_app/get-user-info.js +67 -0
  9. package/dist/actions/django_app/index.d.ts +6 -0
  10. package/dist/actions/django_app/index.js +6 -0
  11. package/dist/actions/django_app/process-data.d.ts +51 -0
  12. package/dist/actions/django_app/process-data.js +75 -0
  13. package/dist/actions/django_app/send-notification.d.ts +55 -0
  14. package/dist/actions/django_app/send-notification.js +78 -0
  15. package/dist/actions/index.d.ts +1 -0
  16. package/dist/actions/index.js +1 -0
  17. package/dist/cli/commands/syncActions.js +49 -8
  18. package/dist/core/eventReceivers.d.ts +2 -2
  19. package/dist/models/django_app/comprehensivemodel.d.ts +47 -0
  20. package/dist/models/django_app/comprehensivemodel.js +63 -0
  21. package/dist/models/django_app/custompkmodel.d.ts +44 -0
  22. package/dist/models/django_app/custompkmodel.js +61 -0
  23. package/dist/models/django_app/deepmodellevel1.d.ts +47 -0
  24. package/dist/models/django_app/deepmodellevel1.js +64 -0
  25. package/dist/models/django_app/deepmodellevel2.d.ts +47 -0
  26. package/dist/models/django_app/deepmodellevel2.js +63 -0
  27. package/dist/models/django_app/deepmodellevel3.d.ts +44 -0
  28. package/dist/models/django_app/deepmodellevel3.js +61 -0
  29. package/dist/models/django_app/dummymodel.d.ts +47 -0
  30. package/dist/models/django_app/dummymodel.js +63 -0
  31. package/dist/models/django_app/dummyrelatedmodel.d.ts +44 -0
  32. package/dist/models/django_app/dummyrelatedmodel.js +61 -0
  33. package/dist/models/django_app/filetest.d.ts +44 -0
  34. package/dist/models/django_app/filetest.js +61 -0
  35. package/dist/models/django_app/index.d.ts +14 -0
  36. package/dist/models/django_app/index.js +14 -0
  37. package/dist/models/django_app/modelwithcustompkrelation.d.ts +47 -0
  38. package/dist/models/django_app/modelwithcustompkrelation.js +63 -0
  39. package/dist/models/django_app/namefiltercustompkmodel.d.ts +44 -0
  40. package/dist/models/django_app/namefiltercustompkmodel.js +61 -0
  41. package/dist/models/django_app/order.d.ts +44 -0
  42. package/dist/models/django_app/order.js +61 -0
  43. package/dist/models/django_app/orderitem.d.ts +47 -0
  44. package/dist/models/django_app/orderitem.js +64 -0
  45. package/dist/models/django_app/product.d.ts +47 -0
  46. package/dist/models/django_app/product.js +63 -0
  47. package/dist/models/django_app/productcategory.d.ts +44 -0
  48. package/dist/models/django_app/productcategory.js +61 -0
  49. package/dist/models/fileobject.d.ts +4 -0
  50. package/dist/models/fileobject.js +9 -0
  51. package/dist/models/index.d.ts +2 -0
  52. package/dist/models/index.js +2 -0
  53. package/dist/syncEngine/metrics/metricOptCalcs.d.ts +3 -3
  54. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ /**
2
+ * This file was auto-generated. Do not make direct changes to the file.
3
+ * Action: Send Notification
4
+ * App: django_app
5
+ */
6
+ import axios from 'axios';
7
+ import { z } from 'zod';
8
+ import { configInstance, parseStateZeroError } from '../../../src';
9
+ /**
10
+ * Zod schema for the input of sendNotification.
11
+ * NOTE: This is an object schema for validating the data payload.
12
+ */
13
+ export const sendNotificationInputSchema = z.object({ message: z.string().max(500),
14
+ recipients: z.array(z.any()),
15
+ priority: z.enum(["low", "high"]).optional().default("low") });
16
+ /**
17
+ * Zod schema for the response of sendNotification.
18
+ */
19
+ export const sendNotificationResponseSchema = z.object({ success: z.boolean(),
20
+ message_id: z.string(),
21
+ sent_to: z.number().int(),
22
+ queued_at: z.string().datetime({ message: "Invalid ISO 8601 datetime string" }) });
23
+ /**
24
+ * Send notifications to multiple recipients
25
+ *
26
+ * @param string message - Notification message to send
27
+ * @param any[] recipients - List of email addresses to notify
28
+ * @param 'low' | 'high' priority - Notification priority level
29
+ * @param {Object} [axiosOverrides] - Allows overriding Axios request parameters.
30
+ * @returns {Promise<Object>} A promise that resolves with the action's result.
31
+ */
32
+ export async function sendNotification(message, recipients, priority = "low", axiosOverrides = {}) {
33
+ // Construct the data payload from the function arguments
34
+ const payload = {
35
+ message,
36
+ recipients,
37
+ priority
38
+ };
39
+ const config = configInstance.getConfig();
40
+ const backend = config.backendConfigs['default'];
41
+ if (!backend) {
42
+ throw new Error(`No backend configuration found for key: default`);
43
+ }
44
+ const baseUrl = backend.API_URL.replace(/\/+$/, '');
45
+ const actionUrl = `${baseUrl}/actions/send_notification/`;
46
+ const headers = backend.getAuthHeaders ? backend.getAuthHeaders() : {};
47
+ try {
48
+ const response = await axios.post(actionUrl, payload, {
49
+ headers: { 'Content-Type': 'application/json', ...headers },
50
+ ...axiosOverrides,
51
+ });
52
+ return sendNotificationResponseSchema.parse(response.data);
53
+ }
54
+ catch (error) {
55
+ if (error instanceof z.ZodError) {
56
+ throw new Error(`Send Notification failed: Invalid response from server. Details: ${error.message}`);
57
+ }
58
+ if (error.response && error.response.data) {
59
+ const parsedError = parseStateZeroError(error.response.data);
60
+ if (Error.captureStackTrace) {
61
+ Error.captureStackTrace(parsedError, sendNotification);
62
+ }
63
+ throw parsedError;
64
+ }
65
+ else if (error.request) {
66
+ throw new Error(`Send Notification failed: No response received from server.`);
67
+ }
68
+ else {
69
+ throw new Error(`Send Notification failed: ${error.message}`);
70
+ }
71
+ }
72
+ }
73
+ export default sendNotification;
74
+ sendNotification.actionName = 'send_notification';
75
+ sendNotification.title = 'Send Notification';
76
+ sendNotification.app = 'django_app';
77
+ sendNotification.permissions = ['CanSendNotifications'];
78
+ sendNotification.configKey = 'default';
@@ -0,0 +1 @@
1
+ export * from "./django_app";
@@ -0,0 +1 @@
1
+ export * from './django_app';
@@ -200,11 +200,11 @@ import { z } from 'zod';
200
200
  import { AxiosRequestConfig } from 'axios';
201
201
 
202
202
  {{#if inputTsSchemaString}}
203
- export type {{functionName}}Input = { {{inputTsSchemaString}} };
203
+ export type {{functionName}}Input = { {{{inputTsSchemaString}}} };
204
204
  {{/if}}
205
205
 
206
206
  {{#if responseTsSchemaString}}
207
- export type {{functionName}}Response = { {{responseTsSchemaString}} };
207
+ export type {{functionName}}Response = { {{{responseTsSchemaString}}} };
208
208
  {{else}}
209
209
  export type {{functionName}}Response = any;
210
210
  {{/if}}
@@ -384,7 +384,8 @@ function prepareActionTemplateData(modulePath, functionName, actionName, actionD
384
384
  const propertyStrings = propertyEntries
385
385
  .map(([name, prop]) => `${name}: ${generateTsTypeForProperty(prop)}`)
386
386
  .join(", ");
387
- return propertyStrings;
387
+ // Wrap in SafeString to prevent Handlebars from escaping quotes
388
+ return new Handlebars.SafeString(propertyStrings);
388
389
  };
389
390
  const inputSchemaString = processProperties(inputProps);
390
391
  const responseSchemaString = processProperties(responseProps);
@@ -436,13 +437,16 @@ function prepareActionTemplateData(modulePath, functionName, actionName, actionD
436
437
  }
437
438
  async function generateActionFile(backend, actionName, actionDefinition) {
438
439
  const functionName = _.camelCase(actionName);
439
- // Apply the same logic as syncModels.js
440
440
  const modulePath = process.env.NODE_ENV === "test" ? "../../../src" : "@statezero/core";
441
441
  const appName = (actionDefinition.app || "general").toLowerCase();
442
442
  const outDir = path.join(backend.GENERATED_ACTIONS_DIR, appName);
443
443
  await fs.mkdir(outDir, { recursive: true });
444
444
  const templateData = prepareActionTemplateData(modulePath, functionName, actionName, actionDefinition, backend.NAME);
445
445
  const fileName = _.kebabCase(actionName);
446
+ // Write the raw schema file (like models do)
447
+ const schemaFilePath = path.join(outDir, `${fileName}.schema.json`);
448
+ await fs.writeFile(schemaFilePath, JSON.stringify(actionDefinition, null, 2));
449
+ // Write JS and TS files
446
450
  const jsFilePath = path.join(outDir, `${fileName}.js`);
447
451
  await fs.writeFile(jsFilePath, jsActionTemplate(templateData));
448
452
  const dtsFilePath = path.join(outDir, `${fileName}.d.ts`);
@@ -461,6 +465,7 @@ async function generateActionFile(backend, actionName, actionDefinition) {
461
465
  }
462
466
  async function generateActionRegistry(generatedFiles, backendConfigs) {
463
467
  const registryByBackend = {};
468
+ const schemasByBackend = {};
464
469
  const allImports = new Set();
465
470
  for (const file of generatedFiles) {
466
471
  const backendKey = file.backend;
@@ -469,6 +474,7 @@ async function generateActionRegistry(generatedFiles, backendConfigs) {
469
474
  registryByBackend[backendKey] = registryByBackend[backendKey] || {
470
475
  actions: {},
471
476
  };
477
+ schemasByBackend[backendKey] = schemasByBackend[backendKey] || {};
472
478
  const functionName = file.functionName;
473
479
  const actionsDir = backendConfigs[backendKey].GENERATED_ACTIONS_DIR;
474
480
  const importPath = path
@@ -477,12 +483,19 @@ async function generateActionRegistry(generatedFiles, backendConfigs) {
477
483
  const importStatement = `import { ${functionName} } from './${importPath}';`;
478
484
  allImports.add(importStatement);
479
485
  registryByBackend[backendKey].actions[file.action] = functionName;
486
+ // Store schema path for getSchema function
487
+ const schemaPath = `./${importPath.replace(/\.js$/, '')}.schema.json`;
488
+ schemasByBackend[backendKey][file.action] = schemaPath;
480
489
  }
481
490
  let registryContent = `/**
482
491
  * This file was auto-generated. Do not make direct changes to the file.
483
492
  * It provides a registry of all generated actions.
484
- */\n\n`;
493
+ */
494
+
495
+ `;
485
496
  registryContent += Array.from(allImports).sort().join("\n") + "\n\n";
497
+ // Add schema paths constant
498
+ registryContent += `const SCHEMA_PATHS = ${JSON.stringify(schemasByBackend, null, 2)};\n\n`;
486
499
  registryContent += `export const ACTION_REGISTRY = {\n`;
487
500
  Object.entries(registryByBackend).forEach(([backendKey, data], index, arr) => {
488
501
  registryContent += ` '${backendKey}': {\n`;
@@ -493,14 +506,43 @@ async function generateActionRegistry(generatedFiles, backendConfigs) {
493
506
  registryContent += ` }${index < arr.length - 1 ? "," : ""}\n`;
494
507
  });
495
508
  registryContent += `};\n\n`;
496
- registryContent += `export function getAction(actionName, configKey) {
509
+ registryContent += `/**
510
+ * Get an action function by name and config key
511
+ * @param {string} actionName - The name of the action
512
+ * @param {string} configKey - The backend config key
513
+ * @returns {Function|null} The action function or null if not found
514
+ */
515
+ export function getAction(actionName, configKey) {
497
516
  const action = ACTION_REGISTRY[configKey]?.[actionName];
498
517
  if (!action) {
499
518
  console.warn(\`Action '\${actionName}' not found for config key '\${configKey}'.\`);
500
519
  return null;
501
520
  }
502
521
  return action;
503
- }\n`;
522
+ }
523
+
524
+ /**
525
+ * Get the full schema for an action by loading its schema file
526
+ * @param {string} actionName - The name of the action
527
+ * @param {string} configKey - The backend config key
528
+ * @returns {Promise<Object|null>} The action schema or null if not found
529
+ */
530
+ export async function getSchema(actionName, configKey) {
531
+ const schemaPath = SCHEMA_PATHS[configKey]?.[actionName];
532
+ if (!schemaPath) {
533
+ console.warn(\`Schema for action '\${actionName}' not found for config key '\${configKey}'.\`);
534
+ return null;
535
+ }
536
+
537
+ try {
538
+ const schema = await import(schemaPath, { assert: { type: 'json' } });
539
+ return schema.default || schema;
540
+ } catch (error) {
541
+ console.error(\`Error loading schema for action '\${actionName}':\`, error);
542
+ return null;
543
+ }
544
+ }
545
+ `;
504
546
  const registryFilePath = path.join(process.cwd(), "action-registry.js");
505
547
  await fs.writeFile(registryFilePath, registryContent);
506
548
  console.log(`\n✨ Generated action registry at ${registryFilePath}`);
@@ -560,7 +602,6 @@ async function main() {
560
602
  });
561
603
  const backendActions = await Promise.all(fetchPromises);
562
604
  const choices = [];
563
- // Reverted to group choices by backend for the CLI prompt
564
605
  for (const { backend, actions } of backendActions) {
565
606
  const actionNames = Object.keys(actions);
566
607
  if (actionNames.length > 0) {
@@ -71,8 +71,8 @@ export class PusherEventReceiver {
71
71
  configKey: string;
72
72
  connectionTimeoutId: NodeJS.Timeout;
73
73
  pusherClient: Pusher;
74
- formatChannelName: (ns: string) => string;
75
- namespaceResolver: (modelName: string) => string;
74
+ formatChannelName: (arg0: string) => string;
75
+ namespaceResolver: NamespaceResolver;
76
76
  channels: Map<any, any>;
77
77
  eventHandlers: Set<any>;
78
78
  /**
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Model-specific QuerySet implementation
3
+ */
4
+ export class ComprehensiveModelQuerySet extends QuerySet<any> {
5
+ constructor(ModelClass: ModelConstructor, config?: {
6
+ nodes?: QueryNode[] | undefined;
7
+ orderBy?: {
8
+ field: string;
9
+ direction: "asc" | "desc";
10
+ }[] | undefined;
11
+ fields?: Set<string> | undefined;
12
+ aggregations?: Aggregation[] | undefined;
13
+ initialQueryset?: string | undefined;
14
+ serializerOptions?: SerializerOptions;
15
+ materialized?: boolean | undefined;
16
+ } | undefined, parent?: null);
17
+ }
18
+ /**
19
+ * Model-specific Manager implementation
20
+ */
21
+ export class ComprehensiveModelManager extends Manager {
22
+ constructor(ModelClass: any);
23
+ }
24
+ /**
25
+ * Implementation of the ComprehensiveModel model
26
+ */
27
+ export class ComprehensiveModel extends Model {
28
+ static configKey: string;
29
+ static modelName: string;
30
+ static primaryKeyField: string;
31
+ static objects: ComprehensiveModelManager;
32
+ static fields: string[];
33
+ static schema: any;
34
+ static relationshipFields: Map<string, {
35
+ ModelClass: () => Function | null;
36
+ relationshipType: string;
37
+ }>;
38
+ constructor(data: any);
39
+ /**
40
+ * Define property getters and setters for all model fields
41
+ * @private
42
+ */
43
+ private _defineProperties;
44
+ }
45
+ import { QuerySet } from '../../../src';
46
+ import { Manager } from '../../../src';
47
+ import { Model } from '../../../src';
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This file was auto-generated. Do not make direct changes to the file.
3
+ */
4
+ import { Model, Manager, QuerySet, getModelClass } from '../../../src';
5
+ import { wrapReactiveModel } from '../../../src';
6
+ import schemaData from './comprehensivemodel.schema.json';
7
+ /**
8
+ * Model-specific QuerySet implementation
9
+ */
10
+ export class ComprehensiveModelQuerySet extends QuerySet {
11
+ }
12
+ /**
13
+ * Model-specific Manager implementation
14
+ */
15
+ export class ComprehensiveModelManager extends Manager {
16
+ constructor(ModelClass) {
17
+ super(ModelClass, ComprehensiveModelQuerySet);
18
+ }
19
+ newQuerySet() {
20
+ return new ComprehensiveModelQuerySet(this.ModelClass);
21
+ }
22
+ }
23
+ /**
24
+ * Implementation of the ComprehensiveModel model
25
+ */
26
+ export class ComprehensiveModel extends Model {
27
+ constructor(data) {
28
+ ComprehensiveModel.validateFields(data);
29
+ super(data);
30
+ // Define getters and setters for all fields
31
+ this._defineProperties();
32
+ return wrapReactiveModel(this);
33
+ }
34
+ /**
35
+ * Define property getters and setters for all model fields
36
+ * @private
37
+ */
38
+ _defineProperties() {
39
+ // For each field, define a property that gets/sets from internal storage
40
+ ComprehensiveModel.fields.forEach(field => {
41
+ Object.defineProperty(this, field, {
42
+ get: function () {
43
+ return this.getField(field);
44
+ },
45
+ set: function (value) {
46
+ this.setField(field, value);
47
+ },
48
+ enumerable: true, // Make sure fields are enumerable for serialization
49
+ configurable: true
50
+ });
51
+ });
52
+ }
53
+ }
54
+ // Bind this model to its backend
55
+ ComprehensiveModel.configKey = 'default';
56
+ ComprehensiveModel.modelName = 'django_app.comprehensivemodel';
57
+ ComprehensiveModel.primaryKeyField = 'id';
58
+ ComprehensiveModel.objects = new ComprehensiveModelManager(ComprehensiveModel);
59
+ ComprehensiveModel.fields = ['id', 'char_field', 'text_field', 'int_field', 'bool_field', 'datetime_field', 'decimal_field', 'json_field', 'money_field_currency', 'money_field', 'related'];
60
+ ComprehensiveModel.schema = schemaData;
61
+ ComprehensiveModel.relationshipFields = new Map([
62
+ ['related', { 'ModelClass': () => getModelClass('django_app.deepmodellevel1', 'default'), 'relationshipType': 'foreign-key' }]
63
+ ]);
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Model-specific QuerySet implementation
3
+ */
4
+ export class CustomPKModelQuerySet extends QuerySet<any> {
5
+ constructor(ModelClass: ModelConstructor, config?: {
6
+ nodes?: QueryNode[] | undefined;
7
+ orderBy?: {
8
+ field: string;
9
+ direction: "asc" | "desc";
10
+ }[] | undefined;
11
+ fields?: Set<string> | undefined;
12
+ aggregations?: Aggregation[] | undefined;
13
+ initialQueryset?: string | undefined;
14
+ serializerOptions?: SerializerOptions;
15
+ materialized?: boolean | undefined;
16
+ } | undefined, parent?: null);
17
+ }
18
+ /**
19
+ * Model-specific Manager implementation
20
+ */
21
+ export class CustomPKModelManager extends Manager {
22
+ constructor(ModelClass: any);
23
+ }
24
+ /**
25
+ * Implementation of the CustomPKModel model
26
+ */
27
+ export class CustomPKModel extends Model {
28
+ static configKey: string;
29
+ static modelName: string;
30
+ static primaryKeyField: string;
31
+ static objects: CustomPKModelManager;
32
+ static fields: string[];
33
+ static schema: any;
34
+ static relationshipFields: Map<any, any>;
35
+ constructor(data: any);
36
+ /**
37
+ * Define property getters and setters for all model fields
38
+ * @private
39
+ */
40
+ private _defineProperties;
41
+ }
42
+ import { QuerySet } from '../../../src';
43
+ import { Manager } from '../../../src';
44
+ import { Model } from '../../../src';
@@ -0,0 +1,61 @@
1
+ /**
2
+ * This file was auto-generated. Do not make direct changes to the file.
3
+ */
4
+ import { Model, Manager, QuerySet, getModelClass } from '../../../src';
5
+ import { wrapReactiveModel } from '../../../src';
6
+ import schemaData from './custompkmodel.schema.json';
7
+ /**
8
+ * Model-specific QuerySet implementation
9
+ */
10
+ export class CustomPKModelQuerySet extends QuerySet {
11
+ }
12
+ /**
13
+ * Model-specific Manager implementation
14
+ */
15
+ export class CustomPKModelManager extends Manager {
16
+ constructor(ModelClass) {
17
+ super(ModelClass, CustomPKModelQuerySet);
18
+ }
19
+ newQuerySet() {
20
+ return new CustomPKModelQuerySet(this.ModelClass);
21
+ }
22
+ }
23
+ /**
24
+ * Implementation of the CustomPKModel model
25
+ */
26
+ export class CustomPKModel extends Model {
27
+ constructor(data) {
28
+ CustomPKModel.validateFields(data);
29
+ super(data);
30
+ // Define getters and setters for all fields
31
+ this._defineProperties();
32
+ return wrapReactiveModel(this);
33
+ }
34
+ /**
35
+ * Define property getters and setters for all model fields
36
+ * @private
37
+ */
38
+ _defineProperties() {
39
+ // For each field, define a property that gets/sets from internal storage
40
+ CustomPKModel.fields.forEach(field => {
41
+ Object.defineProperty(this, field, {
42
+ get: function () {
43
+ return this.getField(field);
44
+ },
45
+ set: function (value) {
46
+ this.setField(field, value);
47
+ },
48
+ enumerable: true, // Make sure fields are enumerable for serialization
49
+ configurable: true
50
+ });
51
+ });
52
+ }
53
+ }
54
+ // Bind this model to its backend
55
+ CustomPKModel.configKey = 'default';
56
+ CustomPKModel.modelName = 'django_app.custompkmodel';
57
+ CustomPKModel.primaryKeyField = 'custom_pk';
58
+ CustomPKModel.objects = new CustomPKModelManager(CustomPKModel);
59
+ CustomPKModel.fields = ['custom_pk', 'name'];
60
+ CustomPKModel.schema = schemaData;
61
+ CustomPKModel.relationshipFields = new Map([]);
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Model-specific QuerySet implementation
3
+ */
4
+ export class DeepModelLevel1QuerySet extends QuerySet<any> {
5
+ constructor(ModelClass: ModelConstructor, config?: {
6
+ nodes?: QueryNode[] | undefined;
7
+ orderBy?: {
8
+ field: string;
9
+ direction: "asc" | "desc";
10
+ }[] | undefined;
11
+ fields?: Set<string> | undefined;
12
+ aggregations?: Aggregation[] | undefined;
13
+ initialQueryset?: string | undefined;
14
+ serializerOptions?: SerializerOptions;
15
+ materialized?: boolean | undefined;
16
+ } | undefined, parent?: null);
17
+ }
18
+ /**
19
+ * Model-specific Manager implementation
20
+ */
21
+ export class DeepModelLevel1Manager extends Manager {
22
+ constructor(ModelClass: any);
23
+ }
24
+ /**
25
+ * Implementation of the DeepModelLevel1 model
26
+ */
27
+ export class DeepModelLevel1 extends Model {
28
+ static configKey: string;
29
+ static modelName: string;
30
+ static primaryKeyField: string;
31
+ static objects: DeepModelLevel1Manager;
32
+ static fields: string[];
33
+ static schema: any;
34
+ static relationshipFields: Map<string, {
35
+ ModelClass: () => Function | null;
36
+ relationshipType: string;
37
+ }>;
38
+ constructor(data: any);
39
+ /**
40
+ * Define property getters and setters for all model fields
41
+ * @private
42
+ */
43
+ private _defineProperties;
44
+ }
45
+ import { QuerySet } from '../../../src';
46
+ import { Manager } from '../../../src';
47
+ import { Model } from '../../../src';
@@ -0,0 +1,64 @@
1
+ /**
2
+ * This file was auto-generated. Do not make direct changes to the file.
3
+ */
4
+ import { Model, Manager, QuerySet, getModelClass } from '../../../src';
5
+ import { wrapReactiveModel } from '../../../src';
6
+ import schemaData from './deepmodellevel1.schema.json';
7
+ /**
8
+ * Model-specific QuerySet implementation
9
+ */
10
+ export class DeepModelLevel1QuerySet extends QuerySet {
11
+ }
12
+ /**
13
+ * Model-specific Manager implementation
14
+ */
15
+ export class DeepModelLevel1Manager extends Manager {
16
+ constructor(ModelClass) {
17
+ super(ModelClass, DeepModelLevel1QuerySet);
18
+ }
19
+ newQuerySet() {
20
+ return new DeepModelLevel1QuerySet(this.ModelClass);
21
+ }
22
+ }
23
+ /**
24
+ * Implementation of the DeepModelLevel1 model
25
+ */
26
+ export class DeepModelLevel1 extends Model {
27
+ constructor(data) {
28
+ DeepModelLevel1.validateFields(data);
29
+ super(data);
30
+ // Define getters and setters for all fields
31
+ this._defineProperties();
32
+ return wrapReactiveModel(this);
33
+ }
34
+ /**
35
+ * Define property getters and setters for all model fields
36
+ * @private
37
+ */
38
+ _defineProperties() {
39
+ // For each field, define a property that gets/sets from internal storage
40
+ DeepModelLevel1.fields.forEach(field => {
41
+ Object.defineProperty(this, field, {
42
+ get: function () {
43
+ return this.getField(field);
44
+ },
45
+ set: function (value) {
46
+ this.setField(field, value);
47
+ },
48
+ enumerable: true, // Make sure fields are enumerable for serialization
49
+ configurable: true
50
+ });
51
+ });
52
+ }
53
+ }
54
+ // Bind this model to its backend
55
+ DeepModelLevel1.configKey = 'default';
56
+ DeepModelLevel1.modelName = 'django_app.deepmodellevel1';
57
+ DeepModelLevel1.primaryKeyField = 'id';
58
+ DeepModelLevel1.objects = new DeepModelLevel1Manager(DeepModelLevel1);
59
+ DeepModelLevel1.fields = ['id', 'name', 'level2', 'comprehensive_models'];
60
+ DeepModelLevel1.schema = schemaData;
61
+ DeepModelLevel1.relationshipFields = new Map([
62
+ ['level2', { 'ModelClass': () => getModelClass('django_app.deepmodellevel2', 'default'), 'relationshipType': 'foreign-key' }],
63
+ ['comprehensive_models', { 'ModelClass': () => getModelClass('django_app.comprehensivemodel', 'default'), 'relationshipType': 'many-to-many' }]
64
+ ]);
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Model-specific QuerySet implementation
3
+ */
4
+ export class DeepModelLevel2QuerySet extends QuerySet<any> {
5
+ constructor(ModelClass: ModelConstructor, config?: {
6
+ nodes?: QueryNode[] | undefined;
7
+ orderBy?: {
8
+ field: string;
9
+ direction: "asc" | "desc";
10
+ }[] | undefined;
11
+ fields?: Set<string> | undefined;
12
+ aggregations?: Aggregation[] | undefined;
13
+ initialQueryset?: string | undefined;
14
+ serializerOptions?: SerializerOptions;
15
+ materialized?: boolean | undefined;
16
+ } | undefined, parent?: null);
17
+ }
18
+ /**
19
+ * Model-specific Manager implementation
20
+ */
21
+ export class DeepModelLevel2Manager extends Manager {
22
+ constructor(ModelClass: any);
23
+ }
24
+ /**
25
+ * Implementation of the DeepModelLevel2 model
26
+ */
27
+ export class DeepModelLevel2 extends Model {
28
+ static configKey: string;
29
+ static modelName: string;
30
+ static primaryKeyField: string;
31
+ static objects: DeepModelLevel2Manager;
32
+ static fields: string[];
33
+ static schema: any;
34
+ static relationshipFields: Map<string, {
35
+ ModelClass: () => Function | null;
36
+ relationshipType: string;
37
+ }>;
38
+ constructor(data: any);
39
+ /**
40
+ * Define property getters and setters for all model fields
41
+ * @private
42
+ */
43
+ private _defineProperties;
44
+ }
45
+ import { QuerySet } from '../../../src';
46
+ import { Manager } from '../../../src';
47
+ import { Model } from '../../../src';
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This file was auto-generated. Do not make direct changes to the file.
3
+ */
4
+ import { Model, Manager, QuerySet, getModelClass } from '../../../src';
5
+ import { wrapReactiveModel } from '../../../src';
6
+ import schemaData from './deepmodellevel2.schema.json';
7
+ /**
8
+ * Model-specific QuerySet implementation
9
+ */
10
+ export class DeepModelLevel2QuerySet extends QuerySet {
11
+ }
12
+ /**
13
+ * Model-specific Manager implementation
14
+ */
15
+ export class DeepModelLevel2Manager extends Manager {
16
+ constructor(ModelClass) {
17
+ super(ModelClass, DeepModelLevel2QuerySet);
18
+ }
19
+ newQuerySet() {
20
+ return new DeepModelLevel2QuerySet(this.ModelClass);
21
+ }
22
+ }
23
+ /**
24
+ * Implementation of the DeepModelLevel2 model
25
+ */
26
+ export class DeepModelLevel2 extends Model {
27
+ constructor(data) {
28
+ DeepModelLevel2.validateFields(data);
29
+ super(data);
30
+ // Define getters and setters for all fields
31
+ this._defineProperties();
32
+ return wrapReactiveModel(this);
33
+ }
34
+ /**
35
+ * Define property getters and setters for all model fields
36
+ * @private
37
+ */
38
+ _defineProperties() {
39
+ // For each field, define a property that gets/sets from internal storage
40
+ DeepModelLevel2.fields.forEach(field => {
41
+ Object.defineProperty(this, field, {
42
+ get: function () {
43
+ return this.getField(field);
44
+ },
45
+ set: function (value) {
46
+ this.setField(field, value);
47
+ },
48
+ enumerable: true, // Make sure fields are enumerable for serialization
49
+ configurable: true
50
+ });
51
+ });
52
+ }
53
+ }
54
+ // Bind this model to its backend
55
+ DeepModelLevel2.configKey = 'default';
56
+ DeepModelLevel2.modelName = 'django_app.deepmodellevel2';
57
+ DeepModelLevel2.primaryKeyField = 'id';
58
+ DeepModelLevel2.objects = new DeepModelLevel2Manager(DeepModelLevel2);
59
+ DeepModelLevel2.fields = ['id', 'name', 'level3'];
60
+ DeepModelLevel2.schema = schemaData;
61
+ DeepModelLevel2.relationshipFields = new Map([
62
+ ['level3', { 'ModelClass': () => getModelClass('django_app.deepmodellevel3', 'default'), 'relationshipType': 'foreign-key' }]
63
+ ]);