@90soft/parse-server-kit 1.0.0

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.
@@ -0,0 +1,95 @@
1
+ import 'reflect-metadata';
2
+ import { ClassAclTemplate, classLevelPermissions, ClassNameType, CompoundIndex } from './types/schemaTypes';
3
+ type OnClassRegistered = (className: string, constructor: Function, fields: Record<string, any>, options: ParseClassOptions) => void;
4
+ type OnFieldRegistered = (constructor: Function, fieldName: string, fieldMeta: Record<string, any>) => void;
5
+ /** Register a hook that runs when @ParseClass is applied. Used by Swagger, Triggers, etc. */
6
+ export declare function onClassRegistered(hook: OnClassRegistered): void;
7
+ /** Register a hook that runs when @ParseField is applied. Used by Swagger, etc. */
8
+ export declare function onFieldRegistered(hook: OnFieldRegistered): void;
9
+ export type AllowedFieldType = {
10
+ type: 'String';
11
+ required?: boolean;
12
+ } | {
13
+ type: 'Number';
14
+ required?: boolean;
15
+ } | {
16
+ type: 'Boolean';
17
+ required?: boolean;
18
+ } | {
19
+ type: 'Date';
20
+ required?: boolean;
21
+ } | {
22
+ type: 'Object';
23
+ required?: boolean;
24
+ } | {
25
+ type: 'Array';
26
+ required?: boolean;
27
+ } | {
28
+ type: 'GeoPoint';
29
+ required?: boolean;
30
+ } | {
31
+ type: 'File';
32
+ required?: boolean;
33
+ } | {
34
+ type: 'Bytes';
35
+ required?: boolean;
36
+ } | {
37
+ type: 'Polygon';
38
+ required?: boolean;
39
+ } | {
40
+ type: 'Pointer';
41
+ targetClass: string;
42
+ required: boolean;
43
+ } | {
44
+ type: 'Relation';
45
+ targetClass: string;
46
+ required: boolean;
47
+ };
48
+ /** Base options for ParseField */
49
+ interface ParseFieldBaseOptions {
50
+ type: AllowedFieldType['type'];
51
+ required?: boolean;
52
+ targetClass?: ClassNameType;
53
+ description?: string;
54
+ indexName?: string;
55
+ min?: number;
56
+ max?: number;
57
+ minLength?: number;
58
+ maxLength?: number;
59
+ enum?: string[];
60
+ pattern?: string;
61
+ }
62
+ interface ParseFieldWithIndex extends ParseFieldBaseOptions {
63
+ index?: boolean | 1 | -1;
64
+ unique?: never;
65
+ }
66
+ interface ParseFieldWithUnique extends ParseFieldBaseOptions {
67
+ index?: never;
68
+ unique?: boolean;
69
+ }
70
+ interface ParseFieldNoIndex extends ParseFieldBaseOptions {
71
+ index?: never;
72
+ unique?: never;
73
+ }
74
+ export type ParseFieldOptions = ParseFieldWithIndex | ParseFieldWithUnique | ParseFieldNoIndex;
75
+ export declare function ParseField(options: ParseFieldOptions): (target: Object, propertyKey: string | symbol) => void;
76
+ export interface ParseClassOptions {
77
+ clp?: classLevelPermissions;
78
+ protectedFields?: {
79
+ [role: string]: string[];
80
+ };
81
+ ACL?: ClassAclTemplate;
82
+ description?: string;
83
+ compoundIndexes?: CompoundIndex[];
84
+ }
85
+ export declare function ParseClass(className: ClassNameType, options?: ParseClassOptions): (constructor: Function) => void;
86
+ export declare function getSchemaDefinition<T>(target: new () => T): {
87
+ compoundIndexes?: CompoundIndex[] | undefined;
88
+ uniqueFields?: string[] | undefined;
89
+ indexes?: Record<string, Record<string, 1 | -1>> | undefined;
90
+ classLevelPermissions?: classLevelPermissions | undefined;
91
+ className: any;
92
+ fields: any;
93
+ };
94
+ export {};
95
+ //# sourceMappingURL=parseDecorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseDecorators.d.ts","sourceRoot":"","sources":["../../src/decorators/parseDecorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EAErB,aAAa,EAEb,aAAa,EAEd,MAAM,qBAAqB,CAAC;AAI7B,KAAK,iBAAiB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;AACrI,KAAK,iBAAiB,GAAG,C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IAC/C,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC;CACnC;AAED,wBAAgB,UAAU,CACxB,SAAS,EAAE,aAAa,EACxB,OAAO,GAAE,iBAAsB,IAEd,aAAa,QAAQ,KAAG,IAAI,CA6B9C;AAID,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC;;;;;;;EAyCzD"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onClassRegistered = onClassRegistered;
4
+ exports.onFieldRegistered = onFieldRegistered;
5
+ exports.ParseField = ParseField;
6
+ exports.ParseClass = ParseClass;
7
+ exports.getSchemaDefinition = getSchemaDefinition;
8
+ require("reflect-metadata");
9
+ const schemaTypes_1 = require("./types/schemaTypes");
10
+ const classHooks = [];
11
+ const fieldHooks = [];
12
+ /** Register a hook that runs when @ParseClass is applied. Used by Swagger, Triggers, etc. */
13
+ function onClassRegistered(hook) {
14
+ classHooks.push(hook);
15
+ }
16
+ /** Register a hook that runs when @ParseField is applied. Used by Swagger, etc. */
17
+ function onFieldRegistered(hook) {
18
+ fieldHooks.push(hook);
19
+ }
20
+ // ── Field Types ──
21
+ const VALID_TYPES = new Set([
22
+ 'String', 'Number', 'Boolean', 'Date', 'Object', 'Array',
23
+ 'GeoPoint', 'File', 'Bytes', 'Polygon', 'Pointer', 'Relation',
24
+ ]);
25
+ // ── @ParseField Decorator ──
26
+ function ParseField(options) {
27
+ const { type, required = false, targetClass, description, indexName, min, max, minLength, maxLength, } = options;
28
+ const enumValues = 'enum' in options ? options.enum : undefined;
29
+ const pattern = 'pattern' in options ? options.pattern : undefined;
30
+ const index = 'index' in options ? options.index : undefined;
31
+ const unique = 'unique' in options ? options.unique : undefined;
32
+ // Validations
33
+ if (!VALID_TYPES.has(type)) {
34
+ throw new Error(`Invalid field type: ${type}. Must be one of ${[...VALID_TYPES].join(', ')}`);
35
+ }
36
+ if ((type === 'Pointer' || type === 'Relation') && !targetClass) {
37
+ throw new Error(`Field of type '${type}' must have a targetClass.`);
38
+ }
39
+ if ((min !== undefined || max !== undefined) && type !== 'Number') {
40
+ throw new Error(`min/max options are only valid for Number type, got '${type}'.`);
41
+ }
42
+ if (min !== undefined && max !== undefined && min > max) {
43
+ throw new Error(`min (${min}) cannot be greater than max (${max}).`);
44
+ }
45
+ if ((minLength !== undefined || maxLength !== undefined) && type !== 'String') {
46
+ throw new Error(`minLength/maxLength options are only valid for String type, got '${type}'.`);
47
+ }
48
+ if (minLength !== undefined && maxLength !== undefined && minLength > maxLength) {
49
+ throw new Error(`minLength (${minLength}) cannot be greater than maxLength (${maxLength}).`);
50
+ }
51
+ if (minLength !== undefined && minLength < 0) {
52
+ throw new Error(`minLength cannot be negative, got ${minLength}.`);
53
+ }
54
+ if (maxLength !== undefined && maxLength < 0) {
55
+ throw new Error(`maxLength cannot be negative, got ${maxLength}.`);
56
+ }
57
+ if (enumValues !== undefined && type !== 'String') {
58
+ throw new Error(`enum option is only valid for String type, got '${type}'.`);
59
+ }
60
+ if (enumValues !== undefined) {
61
+ if (!Array.isArray(enumValues) || enumValues.length === 0) {
62
+ throw new Error(`enum must be a non-empty array of strings.`);
63
+ }
64
+ if (!enumValues.every(v => typeof v === 'string')) {
65
+ throw new Error(`enum values must all be strings.`);
66
+ }
67
+ }
68
+ if (pattern !== undefined && type !== 'String') {
69
+ throw new Error(`pattern option is only valid for String type, got '${type}'.`);
70
+ }
71
+ if (pattern !== undefined) {
72
+ try {
73
+ new RegExp(pattern);
74
+ }
75
+ catch (e) {
76
+ throw new Error(`pattern is not a valid regular expression: ${pattern}`);
77
+ }
78
+ }
79
+ return function (target, propertyKey) {
80
+ const existingFields = Reflect.getMetadata('parse:fields', target.constructor) || {};
81
+ const fieldMeta = {
82
+ type, required,
83
+ ...(targetClass && { targetClass }),
84
+ ...(description && { description }),
85
+ ...(index && { index }),
86
+ ...(indexName && { indexName }),
87
+ ...(unique && { unique }),
88
+ ...(min !== undefined && { min }),
89
+ ...(max !== undefined && { max }),
90
+ ...(minLength !== undefined && { minLength }),
91
+ ...(maxLength !== undefined && { maxLength }),
92
+ ...(enumValues !== undefined && { enum: enumValues }),
93
+ ...(pattern !== undefined && { pattern }),
94
+ };
95
+ existingFields[propertyKey] = fieldMeta;
96
+ Reflect.defineMetadata('parse:fields', existingFields, target.constructor);
97
+ // Define getter and setter for Parse.Object
98
+ Object.defineProperty(target, propertyKey, {
99
+ get() { return this.get(propertyKey); },
100
+ set(value) { this.set(propertyKey, value); },
101
+ enumerable: true,
102
+ configurable: true,
103
+ });
104
+ // Notify hooks
105
+ for (const hook of fieldHooks) {
106
+ hook(target.constructor, propertyKey, fieldMeta);
107
+ }
108
+ };
109
+ }
110
+ function ParseClass(className, options = {}) {
111
+ return function (constructor) {
112
+ Reflect.defineMetadata('parse:className', className, constructor);
113
+ Reflect.defineMetadata('parse:clp', options.clp, constructor);
114
+ Reflect.defineMetadata('parse:protectedFields', options.protectedFields, constructor);
115
+ if (options.ACL) {
116
+ Reflect.defineMetadata('parse:defaultACL', options.ACL, constructor);
117
+ }
118
+ if (options.compoundIndexes) {
119
+ Reflect.defineMetadata('parse:compoundIndexes', options.compoundIndexes, constructor);
120
+ }
121
+ const isRoleSubclass = constructor.prototype instanceof Parse.Role;
122
+ if (!isRoleSubclass) {
123
+ Parse.Object.registerSubclass(className, constructor);
124
+ if (!schemaTypes_1.classNames.includes(className)) {
125
+ schemaTypes_1.classNames.push(className);
126
+ }
127
+ }
128
+ // Notify hooks (Swagger, Triggers, etc.)
129
+ const fields = Reflect.getMetadata('parse:fields', constructor) || {};
130
+ for (const hook of classHooks) {
131
+ hook(className, constructor, fields, options);
132
+ }
133
+ console.log(`Registered Parse class: ${className}`);
134
+ };
135
+ }
136
+ // ── Schema Utility ──
137
+ function getSchemaDefinition(target) {
138
+ const name = Reflect.getMetadata('parse:className', target);
139
+ const fields = Reflect.getMetadata('parse:fields', target) || {};
140
+ const customCLP = Reflect.getMetadata('parse:clp', target) || {};
141
+ const protectedFields = Reflect.getMetadata('parse:protectedFields', target) || {};
142
+ const defaultACL = Reflect.getMetadata('parse:defaultACL', target) || undefined;
143
+ const compoundIndexes = Reflect.getMetadata('parse:compoundIndexes', target) || [];
144
+ let classLevelPermissions;
145
+ if (Object.keys(customCLP).length > 0) {
146
+ classLevelPermissions = { ...customCLP };
147
+ if (Object.keys(protectedFields).length > 0) {
148
+ classLevelPermissions.protectedFields = protectedFields;
149
+ }
150
+ classLevelPermissions.ACL = defaultACL || { '*': { read: true, write: true } };
151
+ }
152
+ const indexes = {};
153
+ const uniqueFields = [];
154
+ for (const [fieldName, fieldMeta] of Object.entries(fields)) {
155
+ const meta = fieldMeta;
156
+ if (meta.index) {
157
+ const indexName = meta.indexName || `${fieldName}_index`;
158
+ const indexOrder = meta.index === -1 ? -1 : 1;
159
+ indexes[indexName] = { [fieldName]: indexOrder };
160
+ }
161
+ if (meta.unique) {
162
+ uniqueFields.push(fieldName);
163
+ }
164
+ }
165
+ return {
166
+ className: name,
167
+ fields,
168
+ ...(classLevelPermissions && { classLevelPermissions }),
169
+ ...(Object.keys(indexes).length > 0 && { indexes }),
170
+ ...(uniqueFields.length > 0 && { uniqueFields }),
171
+ ...(compoundIndexes.length > 0 && { compoundIndexes }),
172
+ };
173
+ }
174
+ //# sourceMappingURL=parseDecorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseDecorators.js","sourceRoot":"","sources":["../../src/decorators/parseDecorators.ts"],"names":[],"mappings":";;AAoBA,8CAEC;AAGD,8CAEC;AA4DD,gCAyFC;AAYD,gCAiCC;AAID,kDAyCC;AA1QD,4BAA0B;AAC1B,qDAQ6B;AAO7B,MAAM,UAAU,GAAwB,EAAE,CAAC;AAC3C,MAAM,UAAU,GAAwB,EAAE,CAAC;AAE3C,6FAA6F;AAC7F,SAAgB,iBAAiB,CAAC,IAAu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E,CAAC;YACf,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,SAAS,QAAQ,CAAC;YACzD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,OAAO,CAAC,SAAS,CAAC,GAAG,EAAC,CAAC,SAAS,CAAC,EAAE,UAAU,EAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO;QACL,SAAS,EAAE,IAAI;QACf,MAAM;QACN,GAAG,CAAC,qBAAqB,IAAI,EAAC,qBAAqB,EAAC,CAAC;QACrD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAC,OAAO,EAAC,CAAC;QACjD,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,EAAC,YAAY,EAAC,CAAC;QAC9C,GAAG,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,IAAI,EAAC,eAAe,EAAC,CAAC;KACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,101 @@
1
+ export declare const classNames: string[];
2
+ export type ClassNameType = string;
3
+ export type CLPParamsOption = {} | '*' | {
4
+ requiresAuthentication: boolean;
5
+ } | {
6
+ [key: string]: boolean;
7
+ };
8
+ export type AllowedFieldType = {
9
+ type: 'String';
10
+ required?: boolean;
11
+ } | {
12
+ type: 'Number';
13
+ required?: boolean;
14
+ } | {
15
+ type: 'Boolean';
16
+ required?: boolean;
17
+ } | {
18
+ type: 'Date';
19
+ required?: boolean;
20
+ } | {
21
+ type: 'Object';
22
+ required?: boolean;
23
+ } | {
24
+ type: 'Array';
25
+ required?: boolean;
26
+ } | {
27
+ type: 'GeoPoint';
28
+ required?: boolean;
29
+ } | {
30
+ type: 'File';
31
+ required?: boolean;
32
+ } | {
33
+ type: 'Bytes';
34
+ required?: boolean;
35
+ } | {
36
+ type: 'Polygon';
37
+ required?: boolean;
38
+ } | {
39
+ type: 'Pointer';
40
+ targetClass: ClassNameType;
41
+ required: boolean;
42
+ } | {
43
+ type: 'Relation';
44
+ targetClass: ClassNameType;
45
+ required: boolean;
46
+ };
47
+ export interface Fields {
48
+ [key: string]: AllowedFieldType;
49
+ }
50
+ export interface Indexes {
51
+ [indexName: string]: {
52
+ [fieldName: string]: number;
53
+ };
54
+ }
55
+ /**
56
+ * Compound index definition for creating indexes on multiple fields
57
+ */
58
+ export interface CompoundIndex {
59
+ /** Array of field names to include in the compound index */
60
+ fields: string[];
61
+ /** Whether this compound index should enforce uniqueness */
62
+ unique?: boolean;
63
+ /** Optional custom index name (defaults to fields joined by underscore + _unique/_index) */
64
+ name?: string;
65
+ /** If true, index only documents that contain the indexed fields (skips null values) */
66
+ sparse?: boolean;
67
+ /**
68
+ * If true, only index documents where ALL indexed fields exist and are not null.
69
+ * This is more reliable than sparse for compound unique indexes.
70
+ */
71
+ partialFilterNulls?: boolean;
72
+ }
73
+ export interface ProtectedFields {
74
+ '*': string[];
75
+ authenticated: string[];
76
+ [key: string]: string[];
77
+ }
78
+ export type AclTemplatePermissions = {
79
+ read?: boolean;
80
+ write?: boolean;
81
+ };
82
+ export type ClassAclTemplate = {
83
+ [key: string]: AclTemplatePermissions;
84
+ };
85
+ export interface classLevelPermissions {
86
+ find?: CLPParamsOption;
87
+ get?: CLPParamsOption;
88
+ count?: CLPParamsOption;
89
+ create?: CLPParamsOption;
90
+ update?: CLPParamsOption;
91
+ delete?: CLPParamsOption;
92
+ protectedFields?: ProtectedFields;
93
+ ACL?: ClassAclTemplate;
94
+ }
95
+ export interface SchemaDefinition {
96
+ className: ClassNameType;
97
+ fields: Fields;
98
+ indexes?: Indexes;
99
+ classLevelPermissions?: classLevelPermissions;
100
+ }
101
+ //# sourceMapping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M,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classNames = void 0;
4
+ // ClassNames are auto-populated by @ParseClass decorator at runtime
5
+ exports.classNames = [];
6
+ //# sourceMappingURL=schemaTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaTypes.js","sourceRoot":"","sources":["../../../src/decorators/types/schemaTypes.ts"],"names":[],"mappings":";;;AAAA,oEAAoE;AACvD,QAAA,UAAU,GAAa,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { ParseClass, ParseField, getSchemaDefinition, onClassRegistered, onFieldRegistered, } from './decorators/parseDecorators';
2
+ export type { ParseClassOptions, ParseFieldOptions, AllowedFieldType, } from './decorators/parseDecorators';
3
+ export { classNames, } from './decorators/types/schemaTypes';
4
+ export type { ClassNameType, CLPParamsOption, classLevelPermissions, ClassAclTemplate, AclTemplatePermissions, ProtectedFields, CompoundIndex, Fields, Indexes, SchemaDefinition, } from './decorators/types/schemaTypes';
5
+ export { BaseModel } from './models/BaseModel';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,UAAU,GACX,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,MAAM,EACN,OAAO,EACP,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // @90soft/parse-server-kit v1.0.0
3
+ // Decorators + BaseModel + Schema Types
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.BaseModel = exports.classNames = exports.onFieldRegistered = exports.onClassRegistered = exports.getSchemaDefinition = exports.ParseField = exports.ParseClass = void 0;
6
+ // Decorators
7
+ var parseDecorators_1 = require("./decorators/parseDecorators");
8
+ Object.defineProperty(exports, "ParseClass", { enumerable: true, get: function () { return parseDecorators_1.ParseClass; } });
9
+ Object.defineProperty(exports, "ParseField", { enumerable: true, get: function () { return parseDecorators_1.ParseField; } });
10
+ Object.defineProperty(exports, "getSchemaDefinition", { enumerable: true, get: function () { return parseDecorators_1.getSchemaDefinition; } });
11
+ Object.defineProperty(exports, "onClassRegistered", { enumerable: true, get: function () { return parseDecorators_1.onClassRegistered; } });
12
+ Object.defineProperty(exports, "onFieldRegistered", { enumerable: true, get: function () { return parseDecorators_1.onFieldRegistered; } });
13
+ // Schema Types
14
+ var schemaTypes_1 = require("./decorators/types/schemaTypes");
15
+ Object.defineProperty(exports, "classNames", { enumerable: true, get: function () { return schemaTypes_1.classNames; } });
16
+ // Base Model
17
+ var BaseModel_1 = require("./models/BaseModel");
18
+ Object.defineProperty(exports, "BaseModel", { enumerable: true, get: function () { return BaseModel_1.BaseModel; } });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,wCAAwC;;;AAExC,aAAa;AACb,gEAMsC;AALpC,6GAAA,UAAU,OAAA;AACV,6GAAA,UAAU,OAAA;AACV,sHAAA,mBAAmB,OAAA;AACnB,oHAAA,iBAAiB,OAAA;AACjB,oHAAA,iBAAiB,OAAA;AAQnB,eAAe;AACf,8DAEwC;AADtC,yGAAA,UAAU,OAAA;AAeZ,aAAa;AACb,gDAA+C;AAAtC,sGAAA,SAAS,OAAA"}
@@ -0,0 +1,15 @@
1
+ declare const ParseObject: new (className?: string) => Parse.Object;
2
+ export declare class BaseModel extends ParseObject {
3
+ /**
4
+ * Configuration for field processing exclusions
5
+ * Classes can override this to exclude specific pointer types
6
+ * from automatic processing in fromParams
7
+ *
8
+ * Default exclusions: IMG and File (require special handling)
9
+ */
10
+ protected static EXCLUDED_POINTER_CLASSES: string[];
11
+ static pointer<T extends typeof BaseModel>(this: T, id: string): InstanceType<T>;
12
+ static fromParams<T extends typeof BaseModel>(this: T, params: any): InstanceType<T>;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=BaseModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseModel.d.ts","sourceRoot":"","sources":["../../src/models/BaseModel.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW,EAA8B,KAAK,SAAS,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC;AAExF,qBAAa,SAAU,SAAQ,WAAW;IACxC;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,CAAC,wBAAwB,EAAE,MAAM,EAAE,CAAmB;IAEtE,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,OAAO,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC;IAMhF,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,OAAO,SAAS,EAC1C,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,GAAG,GACV,YAAY,CAAC,CAAC,CAAC;CA+EnB"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseModel = void 0;
4
+ const ParseObject = Parse.Object;
5
+ class BaseModel extends ParseObject {
6
+ static pointer(id) {
7
+ const obj = new this();
8
+ obj.id = id;
9
+ return obj;
10
+ }
11
+ static fromParams(params) {
12
+ params.className = new this().className;
13
+ const raw = Parse.Object.fromJSON(params, true);
14
+ Object.setPrototypeOf(raw, this.prototype);
15
+ const obj = raw;
16
+ if (params.id)
17
+ obj.id = params.id;
18
+ const fieldsMeta = Reflect.getMetadata('parse:fields', this) || {};
19
+ for (const field in fieldsMeta) {
20
+ const fieldMeta = fieldsMeta[field];
21
+ const fieldType = fieldMeta.type;
22
+ const targetClass = fieldMeta.targetClass;
23
+ const value = params[field];
24
+ if (value === undefined) {
25
+ continue;
26
+ }
27
+ // Check exclusion list (can be overridden by subclasses)
28
+ if (targetClass && this.EXCLUDED_POINTER_CLASSES.includes(targetClass)) {
29
+ continue;
30
+ }
31
+ // Pointer field
32
+ if (fieldType === 'Pointer') {
33
+ if (value === null ||
34
+ (value &&
35
+ typeof value === 'object' &&
36
+ Object.keys(value).length === 0)) {
37
+ obj.set(field, null);
38
+ continue;
39
+ }
40
+ const PointerConstructor = Parse.Object.extend(targetClass);
41
+ const pointerObj = new PointerConstructor();
42
+ if (value && (value.objectId || value.id))
43
+ pointerObj.id = value.objectId || value.id;
44
+ obj.set(field, pointerObj);
45
+ continue;
46
+ }
47
+ // Array of Pointers
48
+ if (fieldType === 'Array' && Array.isArray(value) && targetClass) {
49
+ const PointerConstructor = Parse.Object.extend(targetClass);
50
+ const pointerArray = value.map((item) => {
51
+ const pointerObj = new PointerConstructor();
52
+ pointerObj.id = item.objectId || item.id;
53
+ return pointerObj;
54
+ });
55
+ obj.set(field, pointerArray);
56
+ continue;
57
+ }
58
+ // Embedded object
59
+ if (fieldType === 'Object') {
60
+ obj.set(field, value);
61
+ continue;
62
+ }
63
+ if (fieldType === 'Date') {
64
+ obj.set(field, new Date(value));
65
+ continue;
66
+ }
67
+ if (fieldType === 'GeoPoint') {
68
+ obj.set(field, new Parse.GeoPoint(value));
69
+ continue;
70
+ }
71
+ // Scalar
72
+ obj.set(field, value);
73
+ }
74
+ return obj;
75
+ }
76
+ }
77
+ exports.BaseModel = BaseModel;
78
+ /**
79
+ * Configuration for field processing exclusions
80
+ * Classes can override this to exclude specific pointer types
81
+ * from automatic processing in fromParams
82
+ *
83
+ * Default exclusions: IMG and File (require special handling)
84
+ */
85
+ BaseModel.EXCLUDED_POINTER_CLASSES = ['IMG', 'File'];
86
+ //# sourceMappingURL=BaseModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseModel.js","sourceRoot":"","sources":["../../src/models/BaseModel.ts"],"names":[],"mappings":";;;AAAA,MAAM,WAAW,GAAG,KAAK,CAAC,MAA6D,CAAC;AAExF,MAAa,SAAU,SAAQ,WAAW;IAUxC,MAAM,CAAC,OAAO,CAAsC,EAAU;QAC5D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAqB,CAAC;QAC1C,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;QACZ,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,CAAC,UAAU,CAEf,MAAW;QAEX,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,SAAS,CAAC;QAExC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAChD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,GAAsB,CAAC;QAEnC,IAAI,MAAM,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QAElC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc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",
4
+ "description": "Decorator-driven development kit for Parse Server — @ParseClass, @ParseField, BaseModel, and more.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "parse-server",
16
+ "decorators",
17
+ "typescript",
18
+ "backend",
19
+ "cloud-functions",
20
+ "mongodb"
21
+ ],
22
+ "author": "90Soft",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://git.90-soft.com/90_soft/parse-server-kit.git"
27
+ },
28
+ "peerDependencies": {
29
+ "parse": ">=5.0.0",
30
+ "reflect-metadata": ">=0.1.13"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "^5.5.0",
34
+ "@types/node": "^20.0.0",
35
+ "parse": "^5.3.0",
36
+ "reflect-metadata": "^0.2.2"
37
+ }
38
+ }