@statezero/core 0.1.73 → 0.1.75

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 +55 -12
  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}}
@@ -243,8 +243,10 @@ const dtsActionTemplate = Handlebars.compile(TS_ACTION_DECLARATION_TEMPLATE);
243
243
  // ================================================================================================
244
244
  function generateZodSchemaForProperty(prop) {
245
245
  let zodString;
246
- if (prop.choices && prop.choices.length > 0) {
247
- zodString = `z.enum(${JSON.stringify(prop.choices)})`;
246
+ if (prop.choices && Object.keys(prop.choices).length > 0) {
247
+ // Extract just the keys (values) from the choices dict
248
+ const choiceValues = Object.keys(prop.choices);
249
+ zodString = `z.enum(${JSON.stringify(choiceValues)})`;
248
250
  }
249
251
  else {
250
252
  switch (prop.type) {
@@ -327,8 +329,8 @@ function generateZodSchemaForProperty(prop) {
327
329
  return zodString;
328
330
  }
329
331
  function generateTsTypeForProperty(prop) {
330
- if (prop.choices && prop.choices.length > 0) {
331
- return prop.choices
332
+ if (prop.choices && Object.keys(prop.choices).length > 0) {
333
+ return Object.keys(prop.choices)
332
334
  .map((c) => `'${String(c).replace(/'/g, "\\'")}'`)
333
335
  .join(" | ");
334
336
  }
@@ -384,7 +386,8 @@ function prepareActionTemplateData(modulePath, functionName, actionName, actionD
384
386
  const propertyStrings = propertyEntries
385
387
  .map(([name, prop]) => `${name}: ${generateTsTypeForProperty(prop)}`)
386
388
  .join(", ");
387
- return propertyStrings;
389
+ // Wrap in SafeString to prevent Handlebars from escaping quotes
390
+ return new Handlebars.SafeString(propertyStrings);
388
391
  };
389
392
  const inputSchemaString = processProperties(inputProps);
390
393
  const responseSchemaString = processProperties(responseProps);
@@ -436,13 +439,16 @@ function prepareActionTemplateData(modulePath, functionName, actionName, actionD
436
439
  }
437
440
  async function generateActionFile(backend, actionName, actionDefinition) {
438
441
  const functionName = _.camelCase(actionName);
439
- // Apply the same logic as syncModels.js
440
442
  const modulePath = process.env.NODE_ENV === "test" ? "../../../src" : "@statezero/core";
441
443
  const appName = (actionDefinition.app || "general").toLowerCase();
442
444
  const outDir = path.join(backend.GENERATED_ACTIONS_DIR, appName);
443
445
  await fs.mkdir(outDir, { recursive: true });
444
446
  const templateData = prepareActionTemplateData(modulePath, functionName, actionName, actionDefinition, backend.NAME);
445
447
  const fileName = _.kebabCase(actionName);
448
+ // Write the raw schema file (like models do)
449
+ const schemaFilePath = path.join(outDir, `${fileName}.schema.json`);
450
+ await fs.writeFile(schemaFilePath, JSON.stringify(actionDefinition, null, 2));
451
+ // Write JS and TS files
446
452
  const jsFilePath = path.join(outDir, `${fileName}.js`);
447
453
  await fs.writeFile(jsFilePath, jsActionTemplate(templateData));
448
454
  const dtsFilePath = path.join(outDir, `${fileName}.d.ts`);
@@ -461,6 +467,7 @@ async function generateActionFile(backend, actionName, actionDefinition) {
461
467
  }
462
468
  async function generateActionRegistry(generatedFiles, backendConfigs) {
463
469
  const registryByBackend = {};
470
+ const schemasByBackend = {};
464
471
  const allImports = new Set();
465
472
  for (const file of generatedFiles) {
466
473
  const backendKey = file.backend;
@@ -469,6 +476,7 @@ async function generateActionRegistry(generatedFiles, backendConfigs) {
469
476
  registryByBackend[backendKey] = registryByBackend[backendKey] || {
470
477
  actions: {},
471
478
  };
479
+ schemasByBackend[backendKey] = schemasByBackend[backendKey] || {};
472
480
  const functionName = file.functionName;
473
481
  const actionsDir = backendConfigs[backendKey].GENERATED_ACTIONS_DIR;
474
482
  const importPath = path
@@ -477,12 +485,19 @@ async function generateActionRegistry(generatedFiles, backendConfigs) {
477
485
  const importStatement = `import { ${functionName} } from './${importPath}';`;
478
486
  allImports.add(importStatement);
479
487
  registryByBackend[backendKey].actions[file.action] = functionName;
488
+ // Store schema path for getSchema function
489
+ const schemaPath = `./${importPath.replace(/\.js$/, '')}.schema.json`;
490
+ schemasByBackend[backendKey][file.action] = schemaPath;
480
491
  }
481
492
  let registryContent = `/**
482
493
  * This file was auto-generated. Do not make direct changes to the file.
483
494
  * It provides a registry of all generated actions.
484
- */\n\n`;
495
+ */
496
+
497
+ `;
485
498
  registryContent += Array.from(allImports).sort().join("\n") + "\n\n";
499
+ // Add schema paths constant
500
+ registryContent += `const SCHEMA_PATHS = ${JSON.stringify(schemasByBackend, null, 2)};\n\n`;
486
501
  registryContent += `export const ACTION_REGISTRY = {\n`;
487
502
  Object.entries(registryByBackend).forEach(([backendKey, data], index, arr) => {
488
503
  registryContent += ` '${backendKey}': {\n`;
@@ -493,14 +508,43 @@ async function generateActionRegistry(generatedFiles, backendConfigs) {
493
508
  registryContent += ` }${index < arr.length - 1 ? "," : ""}\n`;
494
509
  });
495
510
  registryContent += `};\n\n`;
496
- registryContent += `export function getAction(actionName, configKey) {
511
+ registryContent += `/**
512
+ * Get an action function by name and config key
513
+ * @param {string} actionName - The name of the action
514
+ * @param {string} configKey - The backend config key
515
+ * @returns {Function|null} The action function or null if not found
516
+ */
517
+ export function getAction(actionName, configKey) {
497
518
  const action = ACTION_REGISTRY[configKey]?.[actionName];
498
519
  if (!action) {
499
520
  console.warn(\`Action '\${actionName}' not found for config key '\${configKey}'.\`);
500
521
  return null;
501
522
  }
502
523
  return action;
503
- }\n`;
524
+ }
525
+
526
+ /**
527
+ * Get the full schema for an action by loading its schema file
528
+ * @param {string} actionName - The name of the action
529
+ * @param {string} configKey - The backend config key
530
+ * @returns {Promise<Object|null>} The action schema or null if not found
531
+ */
532
+ export async function getSchema(actionName, configKey) {
533
+ const schemaPath = SCHEMA_PATHS[configKey]?.[actionName];
534
+ if (!schemaPath) {
535
+ console.warn(\`Schema for action '\${actionName}' not found for config key '\${configKey}'.\`);
536
+ return null;
537
+ }
538
+
539
+ try {
540
+ const schema = await import(schemaPath, { assert: { type: 'json' } });
541
+ return schema.default || schema;
542
+ } catch (error) {
543
+ console.error(\`Error loading schema for action '\${actionName}':\`, error);
544
+ return null;
545
+ }
546
+ }
547
+ `;
504
548
  const registryFilePath = path.join(process.cwd(), "action-registry.js");
505
549
  await fs.writeFile(registryFilePath, registryContent);
506
550
  console.log(`\n✨ Generated action registry at ${registryFilePath}`);
@@ -560,7 +604,6 @@ async function main() {
560
604
  });
561
605
  const backendActions = await Promise.all(fetchPromises);
562
606
  const choices = [];
563
- // Reverted to group choices by backend for the CLI prompt
564
607
  for (const { backend, actions } of backendActions) {
565
608
  const actionNames = Object.keys(actions);
566
609
  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';