@stndrds/schema 0.1.0-alpha.41 → 0.1.0-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4ZUAND4E.mjs → chunk-MXYJTCA3.mjs} +323 -477
- package/dist/{chunk-6ID63D4M.js → chunk-SWD6OPOV.js} +323 -477
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +1 -1
- package/dist/{runtime-Vg_IW6IO.d.mts → runtime-CvRbtIhb.d.mts} +9 -306
- package/dist/{runtime-Vg_IW6IO.d.ts → runtime-CvRbtIhb.d.ts} +9 -306
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -2
- package/dist/runtime.mjs +1 -1
- package/package.json +2 -2
|
@@ -7023,58 +7023,9 @@ declare class RecordService extends TenantAwareService {
|
|
|
7023
7023
|
private permissionService?;
|
|
7024
7024
|
private auditService?;
|
|
7025
7025
|
private policyRegistry;
|
|
7026
|
+
private labelResolver;
|
|
7027
|
+
private rollupContext;
|
|
7026
7028
|
constructor(adapter: DatabaseAdapter, options?: RecordServiceOptions);
|
|
7027
|
-
/**
|
|
7028
|
-
* Check permission for an action on an object.
|
|
7029
|
-
* Only checks if permissionService and userId are configured.
|
|
7030
|
-
* @internal
|
|
7031
|
-
*/
|
|
7032
|
-
private checkPermission;
|
|
7033
|
-
/**
|
|
7034
|
-
* Get policy for an object if one exists and userId is configured.
|
|
7035
|
-
* @internal
|
|
7036
|
-
*/
|
|
7037
|
-
private getPolicy;
|
|
7038
|
-
/**
|
|
7039
|
-
* Build policy context for the current request.
|
|
7040
|
-
* @internal
|
|
7041
|
-
*/
|
|
7042
|
-
private buildPolicyContext;
|
|
7043
|
-
/**
|
|
7044
|
-
* Check if user can access a record based on policy.
|
|
7045
|
-
* Returns true if no policy exists or user can access.
|
|
7046
|
-
* @internal
|
|
7047
|
-
*/
|
|
7048
|
-
private checkRecordAccess;
|
|
7049
|
-
/**
|
|
7050
|
-
* Check if user can modify a record based on policy.
|
|
7051
|
-
* Throws PolicyViolationError if denied.
|
|
7052
|
-
* @internal
|
|
7053
|
-
*/
|
|
7054
|
-
private checkRecordModify;
|
|
7055
|
-
/**
|
|
7056
|
-
* Check if user can delete a record based on policy.
|
|
7057
|
-
* Throws PolicyViolationError if denied.
|
|
7058
|
-
* @internal
|
|
7059
|
-
*/
|
|
7060
|
-
private checkRecordDelete;
|
|
7061
|
-
/**
|
|
7062
|
-
* Resolve relation IDs to their display labels
|
|
7063
|
-
* @internal
|
|
7064
|
-
*/
|
|
7065
|
-
private resolveRelationLabels;
|
|
7066
|
-
/**
|
|
7067
|
-
* Extract relation IDs from a value (string or array)
|
|
7068
|
-
* @internal
|
|
7069
|
-
*/
|
|
7070
|
-
private extractRelationIds;
|
|
7071
|
-
/**
|
|
7072
|
-
* Compute display label from schema expression
|
|
7073
|
-
* Automatically resolves relation attribute values to their labels
|
|
7074
|
-
* and select/multiselect values to their option labels
|
|
7075
|
-
* @internal
|
|
7076
|
-
*/
|
|
7077
|
-
private computeLabel;
|
|
7078
7029
|
/**
|
|
7079
7030
|
* Create a new record with validation
|
|
7080
7031
|
*
|
|
@@ -7084,84 +7035,23 @@ declare class RecordService extends TenantAwareService {
|
|
|
7084
7035
|
* @param data - Record data (attribute values)
|
|
7085
7036
|
* @param options - Creation options
|
|
7086
7037
|
* @returns Created record with computed completionStatus
|
|
7087
|
-
*
|
|
7088
|
-
* @example
|
|
7089
|
-
* ```typescript
|
|
7090
|
-
* const service = new RecordService(adapter, "tenant-123");
|
|
7091
|
-
*
|
|
7092
|
-
* // Create a complete record (strict validation)
|
|
7093
|
-
* const product = await service.createRecord("obj-product", {
|
|
7094
|
-
* name: "Nike Air Max",
|
|
7095
|
-
* price: 129.99,
|
|
7096
|
-
* status: "active"
|
|
7097
|
-
* });
|
|
7098
|
-
* // → product.completionStatus = "complete"
|
|
7099
|
-
*
|
|
7100
|
-
* // Create a draft record (allows missing required fields)
|
|
7101
|
-
* const draft = await service.createRecord("obj-product", {
|
|
7102
|
-
* name: "Draft Product"
|
|
7103
|
-
* }, { allowDraft: true });
|
|
7104
|
-
* // → draft.completionStatus = "draft"
|
|
7105
|
-
* ```
|
|
7106
7038
|
*/
|
|
7107
7039
|
createRecord(objectId: string, data: Record<string, unknown>, options?: {
|
|
7108
|
-
/**
|
|
7109
|
-
* Allow creating records with missing required fields.
|
|
7110
|
-
* Format validation still applies to provided values.
|
|
7111
|
-
* @default false
|
|
7112
|
-
*/
|
|
7113
7040
|
allowDraft?: boolean;
|
|
7114
|
-
/**
|
|
7115
|
-
* Skip all validation (format + relations).
|
|
7116
|
-
* @default true
|
|
7117
|
-
*/
|
|
7118
7041
|
validate?: boolean;
|
|
7119
|
-
/**
|
|
7120
|
-
* Skip relation validation only.
|
|
7121
|
-
* Useful for bulk imports where relations are validated separately.
|
|
7122
|
-
* @default false
|
|
7123
|
-
*/
|
|
7124
7042
|
skipRelationValidation?: boolean;
|
|
7125
|
-
/**
|
|
7126
|
-
* Skip user validation only.
|
|
7127
|
-
* Useful for bulk imports where users are validated separately.
|
|
7128
|
-
* @default false
|
|
7129
|
-
*/
|
|
7130
7043
|
skipUserValidation?: boolean;
|
|
7131
7044
|
skipSystemCheck?: boolean;
|
|
7132
|
-
/**
|
|
7133
|
-
* Skip hook execution.
|
|
7134
|
-
* @default false
|
|
7135
|
-
*/
|
|
7136
7045
|
skipHooks?: boolean;
|
|
7137
|
-
/**
|
|
7138
|
-
* Additional metadata to pass to hooks (e.g., userId, requestId).
|
|
7139
|
-
*/
|
|
7140
7046
|
hookMetadata?: Record<string, unknown>;
|
|
7141
|
-
/**
|
|
7142
|
-
* Developer-managed metadata for the record.
|
|
7143
|
-
* Use this for internal IDs, external references, or any application-specific data.
|
|
7144
|
-
*/
|
|
7145
7047
|
metadata?: Record<string, unknown>;
|
|
7146
7048
|
}): Promise<ObjectRecord>;
|
|
7147
7049
|
/**
|
|
7148
7050
|
* Get a record by ID
|
|
7149
|
-
*
|
|
7150
|
-
* @param recordId - Record UUID
|
|
7151
|
-
* @param options - Query options
|
|
7152
|
-
* @returns Record or null if not found
|
|
7153
7051
|
*/
|
|
7154
7052
|
getRecord(recordId: string, options?: {
|
|
7155
7053
|
includeSchema?: boolean;
|
|
7156
|
-
/**
|
|
7157
|
-
* Skip formula computation (useful for internal operations)
|
|
7158
|
-
* @default false
|
|
7159
|
-
*/
|
|
7160
7054
|
skipFormulas?: boolean;
|
|
7161
|
-
/**
|
|
7162
|
-
* Skip policy access check (internal use only)
|
|
7163
|
-
* @default false
|
|
7164
|
-
*/
|
|
7165
7055
|
skipPolicyCheck?: boolean;
|
|
7166
7056
|
}): Promise<ObjectRecord | null>;
|
|
7167
7057
|
/**
|
|
@@ -7170,206 +7060,41 @@ declare class RecordService extends TenantAwareService {
|
|
|
7170
7060
|
getRecordOrThrow(recordId: string): Promise<ObjectRecord>;
|
|
7171
7061
|
/**
|
|
7172
7062
|
* Update a record with validation
|
|
7173
|
-
*
|
|
7174
|
-
* The completion status is automatically recalculated after each update.
|
|
7175
|
-
* A draft record becomes complete when all required fields are filled.
|
|
7176
|
-
*
|
|
7177
|
-
* Triggers beforeUpdate and afterUpdate hooks if a HookRegistry is configured.
|
|
7178
|
-
*
|
|
7179
|
-
* @param recordId - Record UUID
|
|
7180
|
-
* @param data - Partial data to update
|
|
7181
|
-
* @param options - Update options
|
|
7182
|
-
* @returns Updated record with recalculated completionStatus
|
|
7183
|
-
*
|
|
7184
|
-
* @example
|
|
7185
|
-
* ```typescript
|
|
7186
|
-
* // Update a draft record to make it complete
|
|
7187
|
-
* const updated = await service.updateRecord(draftId, {
|
|
7188
|
-
* price: 99.99,
|
|
7189
|
-
* status: "active"
|
|
7190
|
-
* });
|
|
7191
|
-
* // → updated.completionStatus = "complete" if all required fields now present
|
|
7192
|
-
* ```
|
|
7193
7063
|
*/
|
|
7194
7064
|
updateRecord(recordId: string, data: Partial<Record<string, unknown>>, options?: {
|
|
7195
|
-
/**
|
|
7196
|
-
* Skip validation entirely (format + relations).
|
|
7197
|
-
* @default true
|
|
7198
|
-
*/
|
|
7199
7065
|
validate?: boolean;
|
|
7200
|
-
/**
|
|
7201
|
-
* Allow partial updates without strict validation.
|
|
7202
|
-
* Format validation still applies to provided values.
|
|
7203
|
-
* @default false
|
|
7204
|
-
*/
|
|
7205
7066
|
partial?: boolean;
|
|
7206
|
-
/**
|
|
7207
|
-
* Skip relation validation only.
|
|
7208
|
-
* @default false
|
|
7209
|
-
*/
|
|
7210
7067
|
skipRelationValidation?: boolean;
|
|
7211
|
-
/**
|
|
7212
|
-
* Skip user validation only.
|
|
7213
|
-
* @default false
|
|
7214
|
-
*/
|
|
7215
7068
|
skipUserValidation?: boolean;
|
|
7216
|
-
/**
|
|
7217
|
-
* Skip hook execution.
|
|
7218
|
-
* @default false
|
|
7219
|
-
*/
|
|
7220
7069
|
skipHooks?: boolean;
|
|
7221
|
-
/**
|
|
7222
|
-
* Additional metadata to pass to hooks (e.g., userId, requestId).
|
|
7223
|
-
*/
|
|
7224
7070
|
hookMetadata?: Record<string, unknown>;
|
|
7225
|
-
/**
|
|
7226
|
-
* Developer-managed metadata for the record.
|
|
7227
|
-
* Merged with existing metadata (not replaced).
|
|
7228
|
-
* Set a key to `undefined` to remove it.
|
|
7229
|
-
*
|
|
7230
|
-
* @example
|
|
7231
|
-
* ```typescript
|
|
7232
|
-
* // Existing: { externalId: "ext-123", source: "import" }
|
|
7233
|
-
* // Update with: { source: "api", newKey: "value", externalId: undefined }
|
|
7234
|
-
* // Result: { source: "api", newKey: "value" }
|
|
7235
|
-
* ```
|
|
7236
|
-
*/
|
|
7237
7071
|
metadata?: Record<string, unknown>;
|
|
7238
7072
|
}): Promise<ObjectRecord>;
|
|
7239
7073
|
/**
|
|
7240
|
-
*
|
|
7241
|
-
* @internal
|
|
7242
|
-
*/
|
|
7243
|
-
private buildHookContext;
|
|
7244
|
-
/**
|
|
7245
|
-
* Build hook context for create operations (no existing record)
|
|
7246
|
-
* @internal
|
|
7247
|
-
*/
|
|
7248
|
-
private buildCreateHookContext;
|
|
7249
|
-
/**
|
|
7250
|
-
* Build hook context for delete operations
|
|
7251
|
-
* @internal
|
|
7252
|
-
*/
|
|
7253
|
-
private buildDeleteHookContext;
|
|
7254
|
-
/**
|
|
7255
|
-
* Delete a record
|
|
7256
|
-
*
|
|
7257
|
-
* Triggers beforeDelete and afterDelete hooks if a HookRegistry is configured.
|
|
7258
|
-
*
|
|
7259
|
-
* @param recordId - Record UUID
|
|
7260
|
-
* @param options - Delete options
|
|
7074
|
+
* Delete a record (soft delete)
|
|
7261
7075
|
*/
|
|
7262
7076
|
deleteRecord(recordId: string, options?: {
|
|
7263
7077
|
checkSystem?: boolean;
|
|
7264
|
-
/**
|
|
7265
|
-
* Skip hook execution.
|
|
7266
|
-
* @default false
|
|
7267
|
-
*/
|
|
7268
7078
|
skipHooks?: boolean;
|
|
7269
|
-
/**
|
|
7270
|
-
* Skip relation reference check (use with caution).
|
|
7271
|
-
* @default false
|
|
7272
|
-
*/
|
|
7273
7079
|
skipReferenceCheck?: boolean;
|
|
7274
|
-
/**
|
|
7275
|
-
* Additional metadata to pass to hooks (e.g., userId, requestId).
|
|
7276
|
-
*/
|
|
7277
7080
|
hookMetadata?: Record<string, unknown>;
|
|
7278
7081
|
}): Promise<void>;
|
|
7082
|
+
/**
|
|
7083
|
+
* Permanently delete a record (hard delete)
|
|
7084
|
+
*/
|
|
7085
|
+
hardDeleteRecord(recordId: string): Promise<void>;
|
|
7279
7086
|
/**
|
|
7280
7087
|
* Restore a soft-deleted record
|
|
7281
|
-
*
|
|
7282
|
-
* Triggers beforeRestore and afterRestore hooks if a HookRegistry is configured.
|
|
7283
|
-
*
|
|
7284
|
-
* @param recordId - Record UUID
|
|
7285
|
-
* @param options - Restore options
|
|
7286
|
-
* @returns Restored record
|
|
7287
|
-
*
|
|
7288
|
-
* @example
|
|
7289
|
-
* ```typescript
|
|
7290
|
-
* // Restore a deleted record
|
|
7291
|
-
* const restored = await service.restoreRecord("rec-123");
|
|
7292
|
-
* console.log(restored.deletedAt); // null
|
|
7293
|
-
* ```
|
|
7294
7088
|
*/
|
|
7295
7089
|
restoreRecord(recordId: string, options?: {
|
|
7296
|
-
/**
|
|
7297
|
-
* Skip hook execution.
|
|
7298
|
-
* @default false
|
|
7299
|
-
*/
|
|
7300
7090
|
skipHooks?: boolean;
|
|
7301
|
-
/**
|
|
7302
|
-
* Additional metadata to pass to hooks (e.g., userId, requestId).
|
|
7303
|
-
*/
|
|
7304
7091
|
hookMetadata?: Record<string, unknown>;
|
|
7305
7092
|
}): Promise<ObjectRecord>;
|
|
7306
|
-
/**
|
|
7307
|
-
* Build hook context for restore operations
|
|
7308
|
-
* @internal
|
|
7309
|
-
*/
|
|
7310
|
-
private buildRestoreHookContext;
|
|
7311
|
-
/**
|
|
7312
|
-
* Enrich a record with computed formula values
|
|
7313
|
-
*
|
|
7314
|
-
* Formula attributes are calculated at read-time from the record's values.
|
|
7315
|
-
* This method adds the computed values to the record's values object.
|
|
7316
|
-
*
|
|
7317
|
-
* @param record - The record to enrich
|
|
7318
|
-
* @param schema - The object schema containing attribute definitions
|
|
7319
|
-
* @returns Record with formula values computed
|
|
7320
|
-
* @internal
|
|
7321
|
-
*/
|
|
7322
|
-
private enrichWithFormulas;
|
|
7323
|
-
/**
|
|
7324
|
-
* Enrich multiple records with computed formula values
|
|
7325
|
-
* @internal
|
|
7326
|
-
*/
|
|
7327
|
-
private enrichRecordsWithFormulas;
|
|
7328
|
-
/**
|
|
7329
|
-
* Recalculate rollups after a record changes
|
|
7330
|
-
*
|
|
7331
|
-
* This handles three cases:
|
|
7332
|
-
* 1. The record itself has rollups (e.g., aggregating from related records it points to)
|
|
7333
|
-
* 2. Parent records have rollups that aggregate from this record (reverse pattern)
|
|
7334
|
-
* 3. Records that have forward rollups pointing to this record (forward pattern)
|
|
7335
|
-
*
|
|
7336
|
-
* @param record - The record that was modified
|
|
7337
|
-
* @param schema - Schema of the record's object
|
|
7338
|
-
* @internal
|
|
7339
|
-
*/
|
|
7340
|
-
private recalculateParentRollups;
|
|
7341
|
-
/**
|
|
7342
|
-
* Permanently delete a record (hard delete)
|
|
7343
|
-
*
|
|
7344
|
-
* This cannot be undone. Use with caution - prefer soft delete for data safety.
|
|
7345
|
-
* Does NOT trigger delete hooks (already triggered on soft delete).
|
|
7346
|
-
*
|
|
7347
|
-
* @param recordId - Record UUID
|
|
7348
|
-
*
|
|
7349
|
-
* @example
|
|
7350
|
-
* ```typescript
|
|
7351
|
-
* // Permanently delete a record
|
|
7352
|
-
* await service.hardDeleteRecord("rec-123");
|
|
7353
|
-
* ```
|
|
7354
|
-
*/
|
|
7355
|
-
hardDeleteRecord(recordId: string): Promise<void>;
|
|
7356
7093
|
/**
|
|
7357
7094
|
* List records for an object with pagination
|
|
7358
|
-
*
|
|
7359
|
-
* @param objectId - Object UUID
|
|
7360
|
-
* @param options - List options
|
|
7361
|
-
* @returns Records and total count
|
|
7362
7095
|
*/
|
|
7363
7096
|
listRecords(objectId: string, options?: ListOptions & {
|
|
7364
|
-
/**
|
|
7365
|
-
* Skip formula computation (useful for internal operations)
|
|
7366
|
-
* @default false
|
|
7367
|
-
*/
|
|
7368
7097
|
skipFormulas?: boolean;
|
|
7369
|
-
/**
|
|
7370
|
-
* Skip policy filtering (internal use only)
|
|
7371
|
-
* @default false
|
|
7372
|
-
*/
|
|
7373
7098
|
skipPolicyFilter?: boolean;
|
|
7374
7099
|
}): Promise<{
|
|
7375
7100
|
records: ObjectRecord[];
|
|
@@ -7377,17 +7102,8 @@ declare class RecordService extends TenantAwareService {
|
|
|
7377
7102
|
}>;
|
|
7378
7103
|
/**
|
|
7379
7104
|
* Search records using full-text search
|
|
7380
|
-
*
|
|
7381
|
-
* @param objectId - Object UUID
|
|
7382
|
-
* @param query - Search query
|
|
7383
|
-
* @param options - Search options
|
|
7384
|
-
* @returns Matching records and total count
|
|
7385
7105
|
*/
|
|
7386
7106
|
searchRecords(objectId: string, query: string, options?: SearchOptions & {
|
|
7387
|
-
/**
|
|
7388
|
-
* Skip formula computation (useful for internal operations)
|
|
7389
|
-
* @default false
|
|
7390
|
-
*/
|
|
7391
7107
|
skipFormulas?: boolean;
|
|
7392
7108
|
}): Promise<{
|
|
7393
7109
|
records: ObjectRecord[];
|
|
@@ -7395,27 +7111,14 @@ declare class RecordService extends TenantAwareService {
|
|
|
7395
7111
|
}>;
|
|
7396
7112
|
/**
|
|
7397
7113
|
* Validate data against object schema without saving
|
|
7398
|
-
*
|
|
7399
|
-
* @param objectId - Object UUID
|
|
7400
|
-
* @param data - Data to validate
|
|
7401
|
-
* @returns Validation result
|
|
7402
7114
|
*/
|
|
7403
7115
|
validateData(objectId: string, data: Record<string, unknown>): Promise<ValidationResult>;
|
|
7404
7116
|
/**
|
|
7405
|
-
* Compute the completion status for given data without saving
|
|
7406
|
-
* Useful for UI to show draft/complete status before submitting.
|
|
7407
|
-
*
|
|
7408
|
-
* @param objectId - Object UUID
|
|
7409
|
-
* @param data - Data to check
|
|
7410
|
-
* @returns Computed completion status
|
|
7117
|
+
* Compute the completion status for given data without saving
|
|
7411
7118
|
*/
|
|
7412
7119
|
computeStatus(objectId: string, data: Record<string, unknown>): Promise<CompletionStatus>;
|
|
7413
7120
|
/**
|
|
7414
|
-
* Refresh the completion status of an existing record
|
|
7415
|
-
* Useful when schema changes and you need to recompute statuses.
|
|
7416
|
-
*
|
|
7417
|
-
* @param recordId - Record UUID
|
|
7418
|
-
* @returns Updated completion status
|
|
7121
|
+
* Refresh the completion status of an existing record
|
|
7419
7122
|
*/
|
|
7420
7123
|
refreshRecordStatus(recordId: string): Promise<CompletionStatus>;
|
|
7421
7124
|
}
|