@rippling/rippling-sdk 0.2.0-alpha.85 → 0.2.0-alpha.86

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 (140) hide show
  1. package/core/platform/custom-objects/category.d.mts +125 -0
  2. package/core/platform/custom-objects/category.d.mts.map +1 -0
  3. package/core/platform/custom-objects/category.d.ts +125 -0
  4. package/core/platform/custom-objects/category.d.ts.map +1 -0
  5. package/core/platform/custom-objects/category.js +188 -0
  6. package/core/platform/custom-objects/category.js.map +1 -0
  7. package/core/platform/custom-objects/category.mjs +178 -0
  8. package/core/platform/custom-objects/category.mjs.map +1 -0
  9. package/core/platform/custom-objects/definition.d.mts +147 -0
  10. package/core/platform/custom-objects/definition.d.mts.map +1 -0
  11. package/core/platform/custom-objects/definition.d.ts +147 -0
  12. package/core/platform/custom-objects/definition.d.ts.map +1 -0
  13. package/core/platform/custom-objects/definition.js +200 -0
  14. package/core/platform/custom-objects/definition.js.map +1 -0
  15. package/core/platform/custom-objects/definition.mjs +190 -0
  16. package/core/platform/custom-objects/definition.mjs.map +1 -0
  17. package/core/platform/custom-objects/fields.d.mts +302 -0
  18. package/core/platform/custom-objects/fields.d.mts.map +1 -0
  19. package/core/platform/custom-objects/fields.d.ts +302 -0
  20. package/core/platform/custom-objects/fields.d.ts.map +1 -0
  21. package/core/platform/custom-objects/fields.js +369 -0
  22. package/core/platform/custom-objects/fields.js.map +1 -0
  23. package/core/platform/custom-objects/fields.mjs +347 -0
  24. package/core/platform/custom-objects/fields.mjs.map +1 -0
  25. package/core/platform/custom-objects/function-runtime.d.mts +42 -0
  26. package/core/platform/custom-objects/function-runtime.d.mts.map +1 -0
  27. package/core/platform/custom-objects/function-runtime.d.ts +42 -0
  28. package/core/platform/custom-objects/function-runtime.d.ts.map +1 -0
  29. package/core/platform/custom-objects/function-runtime.js +38 -0
  30. package/core/platform/custom-objects/function-runtime.js.map +1 -0
  31. package/core/platform/custom-objects/function-runtime.mjs +35 -0
  32. package/core/platform/custom-objects/function-runtime.mjs.map +1 -0
  33. package/core/platform/custom-objects/lifecycle.d.mts +83 -0
  34. package/core/platform/custom-objects/lifecycle.d.mts.map +1 -0
  35. package/core/platform/custom-objects/lifecycle.d.ts +83 -0
  36. package/core/platform/custom-objects/lifecycle.d.ts.map +1 -0
  37. package/core/platform/custom-objects/lifecycle.js +372 -0
  38. package/core/platform/custom-objects/lifecycle.js.map +1 -0
  39. package/core/platform/custom-objects/lifecycle.mjs +367 -0
  40. package/core/platform/custom-objects/lifecycle.mjs.map +1 -0
  41. package/core/platform/custom-objects/manager.d.mts +354 -0
  42. package/core/platform/custom-objects/manager.d.mts.map +1 -0
  43. package/core/platform/custom-objects/manager.d.ts +354 -0
  44. package/core/platform/custom-objects/manager.d.ts.map +1 -0
  45. package/core/platform/custom-objects/manager.js +646 -0
  46. package/core/platform/custom-objects/manager.js.map +1 -0
  47. package/core/platform/custom-objects/manager.mjs +637 -0
  48. package/core/platform/custom-objects/manager.mjs.map +1 -0
  49. package/core/platform/custom-objects/provisioning.d.mts +138 -0
  50. package/core/platform/custom-objects/provisioning.d.mts.map +1 -0
  51. package/core/platform/custom-objects/provisioning.d.ts +138 -0
  52. package/core/platform/custom-objects/provisioning.d.ts.map +1 -0
  53. package/core/platform/custom-objects/provisioning.js +455 -0
  54. package/core/platform/custom-objects/provisioning.js.map +1 -0
  55. package/core/platform/custom-objects/provisioning.mjs +447 -0
  56. package/core/platform/custom-objects/provisioning.mjs.map +1 -0
  57. package/core/platform/custom-objects/rql.d.mts +122 -0
  58. package/core/platform/custom-objects/rql.d.mts.map +1 -0
  59. package/core/platform/custom-objects/rql.d.ts +122 -0
  60. package/core/platform/custom-objects/rql.d.ts.map +1 -0
  61. package/core/platform/custom-objects/rql.js +225 -0
  62. package/core/platform/custom-objects/rql.js.map +1 -0
  63. package/core/platform/custom-objects/rql.mjs +222 -0
  64. package/core/platform/custom-objects/rql.mjs.map +1 -0
  65. package/core/platform/custom-objects/schema-manager.d.mts +203 -0
  66. package/core/platform/custom-objects/schema-manager.d.mts.map +1 -0
  67. package/core/platform/custom-objects/schema-manager.d.ts +203 -0
  68. package/core/platform/custom-objects/schema-manager.d.ts.map +1 -0
  69. package/core/platform/custom-objects/schema-manager.js +256 -0
  70. package/core/platform/custom-objects/schema-manager.js.map +1 -0
  71. package/core/platform/custom-objects/schema-manager.mjs +249 -0
  72. package/core/platform/custom-objects/schema-manager.mjs.map +1 -0
  73. package/core/platform/custom-objects/typed-rql.d.mts +157 -0
  74. package/core/platform/custom-objects/typed-rql.d.mts.map +1 -0
  75. package/core/platform/custom-objects/typed-rql.d.ts +157 -0
  76. package/core/platform/custom-objects/typed-rql.d.ts.map +1 -0
  77. package/core/platform/custom-objects/typed-rql.js +583 -0
  78. package/core/platform/custom-objects/typed-rql.js.map +1 -0
  79. package/core/platform/custom-objects/typed-rql.mjs +580 -0
  80. package/core/platform/custom-objects/typed-rql.mjs.map +1 -0
  81. package/core/platform/custom-objects/types.d.mts +549 -0
  82. package/core/platform/custom-objects/types.d.mts.map +1 -0
  83. package/core/platform/custom-objects/types.d.ts +549 -0
  84. package/core/platform/custom-objects/types.d.ts.map +1 -0
  85. package/core/platform/custom-objects/types.js +20 -0
  86. package/core/platform/custom-objects/types.js.map +1 -0
  87. package/core/platform/custom-objects/types.mjs +17 -0
  88. package/core/platform/custom-objects/types.mjs.map +1 -0
  89. package/core/platform/custom-objects/validation.d.mts +97 -0
  90. package/core/platform/custom-objects/validation.d.mts.map +1 -0
  91. package/core/platform/custom-objects/validation.d.ts +97 -0
  92. package/core/platform/custom-objects/validation.d.ts.map +1 -0
  93. package/core/platform/custom-objects/validation.js +477 -0
  94. package/core/platform/custom-objects/validation.js.map +1 -0
  95. package/core/platform/custom-objects/validation.mjs +465 -0
  96. package/core/platform/custom-objects/validation.mjs.map +1 -0
  97. package/core/platform/custom-objects.d.mts +67 -0
  98. package/core/platform/custom-objects.d.mts.map +1 -0
  99. package/core/platform/custom-objects.d.ts +67 -0
  100. package/core/platform/custom-objects.d.ts.map +1 -0
  101. package/core/platform/custom-objects.js +118 -0
  102. package/core/platform/custom-objects.js.map +1 -0
  103. package/core/platform/custom-objects.mjs +45 -0
  104. package/core/platform/custom-objects.mjs.map +1 -0
  105. package/package.json +1 -1
  106. package/resources/custom-objects/custom-objects.d.mts +7 -0
  107. package/resources/custom-objects/custom-objects.d.mts.map +1 -1
  108. package/resources/custom-objects/custom-objects.d.ts +7 -0
  109. package/resources/custom-objects/custom-objects.d.ts.map +1 -1
  110. package/resources/custom-objects/custom-objects.js.map +1 -1
  111. package/resources/custom-objects/custom-objects.mjs.map +1 -1
  112. package/resources/custom-objects/fields.d.mts +129 -54
  113. package/resources/custom-objects/fields.d.mts.map +1 -1
  114. package/resources/custom-objects/fields.d.ts +129 -54
  115. package/resources/custom-objects/fields.d.ts.map +1 -1
  116. package/resources/levels.d.mts +25 -4
  117. package/resources/levels.d.mts.map +1 -1
  118. package/resources/levels.d.ts +25 -4
  119. package/resources/levels.d.ts.map +1 -1
  120. package/src/core/platform/custom-objects/category.ts +294 -0
  121. package/src/core/platform/custom-objects/definition.ts +373 -0
  122. package/src/core/platform/custom-objects/fields.ts +653 -0
  123. package/src/core/platform/custom-objects/function-runtime.ts +76 -0
  124. package/src/core/platform/custom-objects/lifecycle.ts +557 -0
  125. package/src/core/platform/custom-objects/manager.ts +959 -0
  126. package/src/core/platform/custom-objects/provisioning.ts +672 -0
  127. package/src/core/platform/custom-objects/rql.ts +375 -0
  128. package/src/core/platform/custom-objects/schema-manager.ts +351 -0
  129. package/src/core/platform/custom-objects/typed-rql.ts +1273 -0
  130. package/src/core/platform/custom-objects/types.ts +753 -0
  131. package/src/core/platform/custom-objects/validation.ts +573 -0
  132. package/src/core/platform/custom-objects.ts +269 -0
  133. package/src/resources/custom-objects/custom-objects.ts +8 -0
  134. package/src/resources/custom-objects/fields.ts +192 -59
  135. package/src/resources/levels.ts +28 -4
  136. package/src/version.ts +1 -1
  137. package/version.d.mts +1 -1
  138. package/version.d.ts +1 -1
  139. package/version.js +1 -1
  140. package/version.mjs +1 -1
@@ -0,0 +1,147 @@
1
+ import type { CustomObjectCategoryDefinition } from "./category.mjs";
2
+ import type { AnyCustomObjectDefinition, AnyFieldDefinition, CategoryApiName, CustomObjectApiName, CustomObjectDefinition, FieldDefinitions, FieldNames, LogicalCategoryName, LogicalCustomFieldName, LogicalCustomObjectName, NameFieldDefinition, SectionDefinitions } from "./types.mjs";
3
+ /**
4
+ * Internal input shape accepted by {@link defineCustomObject} before normalization.
5
+ *
6
+ * @typeParam TObjectName - Logical custom-object name for the definition.
7
+ * @typeParam TCategoryName - Logical category name associated with the object.
8
+ * @typeParam TSections - Section map available to field definitions.
9
+ * @typeParam TFields - Field map keyed by logical custom-field names.
10
+ * @typeParam TNameField - Optional name-field behavior supplied by the caller.
11
+ */
12
+ type CategoryInput<TCategoryName extends string> = LogicalCategoryName<TCategoryName> | CustomObjectCategoryDefinition<LogicalCategoryName<TCategoryName>>;
13
+ /**
14
+ * Internal input shape accepted by {@link defineCustomObject} before normalization.
15
+ *
16
+ * @typeParam TObjectName - Logical custom-object name for the definition.
17
+ * @typeParam TCategoryName - Logical category name associated with the object.
18
+ * @typeParam TSections - Section map available to field definitions.
19
+ * @typeParam TFields - Field map keyed by logical custom-field names.
20
+ * @typeParam TNameField - Optional name-field behavior supplied by the caller.
21
+ */
22
+ interface CustomObjectDefinitionInput<TObjectName extends string, TCategoryName extends string, TSections extends SectionDefinitions, TFields extends FieldDefinitions, TNameField extends NameFieldDefinition> {
23
+ readonly name: LogicalCustomObjectName<TObjectName>;
24
+ readonly displayName: string;
25
+ readonly pluralLabel?: string;
26
+ readonly category: CategoryInput<TCategoryName>;
27
+ readonly ownerRole?: string;
28
+ readonly enableHistory?: boolean;
29
+ readonly description: string;
30
+ readonly icon?: {
31
+ readonly emoji?: string | null;
32
+ readonly ripplingIcon?: string | null;
33
+ readonly s3Bucket?: string;
34
+ readonly s3Key?: string;
35
+ };
36
+ readonly nameField?: TNameField;
37
+ readonly sections?: TSections;
38
+ readonly fields: ValidateFieldMap<TFields>;
39
+ }
40
+ /**
41
+ * Rejects extension objects that try to redefine keys already present on the base definition.
42
+ *
43
+ * @typeParam TExisting - Existing key set on the base definition.
44
+ * @typeParam TAdded - Proposed extension object.
45
+ */
46
+ type NoOverlappingKeys<TExisting extends object, TAdded extends object> = Extract<keyof TExisting, keyof TAdded> extends never ? TAdded : never;
47
+ /**
48
+ * Converts a logical field map into a version whose keys must all satisfy the
49
+ * logical custom-field name contract.
50
+ *
51
+ * @typeParam TFields - Candidate logical field map supplied by callers.
52
+ */
53
+ type ValidateFieldMap<TFields extends FieldDefinitions> = {
54
+ readonly [K in keyof TFields]: K extends string ? LogicalCustomFieldName<K> extends never ? never : TFields[K] : never;
55
+ };
56
+ /**
57
+ * Appends the platform-required `__c` suffix to a logical custom-object name.
58
+ *
59
+ * @param name - Logical unsuffixed custom-object name.
60
+ * @returns Wire-level custom-object API name with the required `__c` suffix.
61
+ * @typeParam TObjectName - Logical custom-object name to compile.
62
+ */
63
+ export declare function toCustomObjectApiName<TObjectName extends string>(name: LogicalCustomObjectName<TObjectName>): CustomObjectApiName<TObjectName>;
64
+ /**
65
+ * Appends the platform-required `__c` suffix to a logical custom-field name.
66
+ *
67
+ * @param name - Logical unsuffixed custom-field name.
68
+ * @returns Wire-level custom-field API name with the required `__c` suffix.
69
+ * @typeParam TFieldName - Logical custom-field name to compile.
70
+ */
71
+ export declare function toCustomFieldApiName<TFieldName extends string>(name: LogicalCustomFieldName<TFieldName>): `${TFieldName}__c`;
72
+ /**
73
+ * Appends the platform-required `__c` suffix to a logical category name.
74
+ *
75
+ * @param name - Logical unsuffixed category name.
76
+ * @returns Wire-level category API name with the required `__c` suffix.
77
+ * @typeParam TCategoryName - Logical category name to compile.
78
+ */
79
+ export declare function toCustomCategoryApiName<TCategoryName extends string>(name: LogicalCategoryName<TCategoryName>): CategoryApiName<TCategoryName>;
80
+ /**
81
+ * Defines an immutable, strongly typed custom-object schema.
82
+ *
83
+ * Callers author only logical snake_case names. The returned value includes the
84
+ * derived wire-level api names so downstream tooling can emit valid manifest
85
+ * payloads without requiring authors to know about the `__c` suffix contract.
86
+ *
87
+ * @typeParam TObjectName - Logical custom-object name for the definition.
88
+ * @typeParam TCategoryName - Logical category name associated with the object.
89
+ * @typeParam TSections - Section map available to field definitions.
90
+ * @typeParam TFields - Field map keyed by logical custom-field names.
91
+ * @param definition - Author-facing typed schema definition to normalize, validate, and freeze.
92
+ * @returns Immutable normalized custom-object definition with compiled field and object API names.
93
+ * @typeParam TNameField - Name-field behavior for the object.
94
+ */
95
+ export declare function defineCustomObject<TObjectName extends string, TCategoryName extends string, TSections extends SectionDefinitions = {}, TFields extends FieldDefinitions = FieldDefinitions, TNameField extends NameFieldDefinition = {
96
+ kind: 'text';
97
+ }>(definition: CustomObjectDefinitionInput<TObjectName, TCategoryName, TSections, TFields, TNameField>): Readonly<CustomObjectDefinition<LogicalCustomObjectName<TObjectName>, LogicalCategoryName<TCategoryName>, TSections, TFields, TNameField>>;
98
+ /**
99
+ * Extends an existing object definition without losing type information.
100
+ *
101
+ * This helper is useful when a platform package wants to publish a base schema
102
+ * and another package wants to add fields or sections in a type-safe way.
103
+ *
104
+ * @typeParam TBase - Existing object definition being extended.
105
+ * @typeParam TAddedSections - New section definitions merged into the base object.
106
+ * @param base - Existing typed object definition to extend.
107
+ * @param extension - Additional metadata, sections, and fields to merge into the base definition.
108
+ * @returns New immutable custom-object definition preserving the combined type information.
109
+ * @typeParam TAddedFields - New field definitions merged into the base object.
110
+ */
111
+ export declare function extendCustomObject<TBase extends AnyCustomObjectDefinition, TAddedSections extends SectionDefinitions = {}, TAddedFields extends FieldDefinitions = {}>(base: TBase, extension: {
112
+ readonly displayName?: string;
113
+ readonly pluralLabel?: string;
114
+ readonly ownerRole?: string;
115
+ readonly enableHistory?: boolean;
116
+ readonly description?: string;
117
+ readonly icon?: TBase['icon'];
118
+ readonly sections?: NoOverlappingKeys<TBase['sections'], TAddedSections>;
119
+ readonly fields?: NoOverlappingKeys<TBase['fields'], ValidateFieldMap<TAddedFields>>;
120
+ }): Readonly<CustomObjectDefinition<TBase['name'], TBase['category'], TBase['sections'] & TAddedSections, Omit<TBase['fields'], never> & TAddedFields, TBase['nameField']>>;
121
+ /**
122
+ * Returns the logical custom field names defined on an object.
123
+ *
124
+ * @param definition - Object definition whose logical field names should be returned.
125
+ * @returns Frozen array of logical field names from the definition.
126
+ * @typeParam TDefinition - Object definition whose field names should be returned.
127
+ */
128
+ export declare function fieldNames<TDefinition extends AnyCustomObjectDefinition>(definition: TDefinition): ReadonlyArray<FieldNames<TDefinition>>;
129
+ /**
130
+ * Retrieves a field definition by logical field name with precise typing.
131
+ *
132
+ * @param definition - Object definition that owns the field.
133
+ * @param fieldName - Logical field name to retrieve.
134
+ * @returns Precisely typed field definition for the requested logical field name.
135
+ * @typeParam TDefinition - Object definition that owns the field.
136
+ * @typeParam TFieldName - Logical field name being retrieved.
137
+ */
138
+ export declare function getFieldDefinition<TDefinition extends AnyCustomObjectDefinition, TFieldName extends FieldNames<TDefinition>>(definition: TDefinition, fieldName: TFieldName): TDefinition['fields'][TFieldName];
139
+ /**
140
+ * Returns whether one typed field definition is writable by record create/update helpers.
141
+ *
142
+ * @param field - Typed field definition to inspect.
143
+ * @returns Whether the field may be written by callers.
144
+ */
145
+ export declare function isWritableField(field: AnyFieldDefinition): boolean;
146
+ export {};
147
+ //# sourceMappingURL=definition.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.mts","sourceRoot":"","sources":["../../../src/core/platform/custom-objects/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,uBAAmB;AACjE,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,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AW,SAAS,yBAAyB,EAC7C,UAAU,SAAS,UAAU,CAAC,WAAW,CAAC,EAC1C,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAElE"}
@@ -0,0 +1,147 @@
1
+ import type { CustomObjectCategoryDefinition } from "./category.js";
2
+ import type { AnyCustomObjectDefinition, AnyFieldDefinition, CategoryApiName, CustomObjectApiName, CustomObjectDefinition, FieldDefinitions, FieldNames, LogicalCategoryName, LogicalCustomFieldName, LogicalCustomObjectName, NameFieldDefinition, SectionDefinitions } from "./types.js";
3
+ /**
4
+ * Internal input shape accepted by {@link defineCustomObject} before normalization.
5
+ *
6
+ * @typeParam TObjectName - Logical custom-object name for the definition.
7
+ * @typeParam TCategoryName - Logical category name associated with the object.
8
+ * @typeParam TSections - Section map available to field definitions.
9
+ * @typeParam TFields - Field map keyed by logical custom-field names.
10
+ * @typeParam TNameField - Optional name-field behavior supplied by the caller.
11
+ */
12
+ type CategoryInput<TCategoryName extends string> = LogicalCategoryName<TCategoryName> | CustomObjectCategoryDefinition<LogicalCategoryName<TCategoryName>>;
13
+ /**
14
+ * Internal input shape accepted by {@link defineCustomObject} before normalization.
15
+ *
16
+ * @typeParam TObjectName - Logical custom-object name for the definition.
17
+ * @typeParam TCategoryName - Logical category name associated with the object.
18
+ * @typeParam TSections - Section map available to field definitions.
19
+ * @typeParam TFields - Field map keyed by logical custom-field names.
20
+ * @typeParam TNameField - Optional name-field behavior supplied by the caller.
21
+ */
22
+ interface CustomObjectDefinitionInput<TObjectName extends string, TCategoryName extends string, TSections extends SectionDefinitions, TFields extends FieldDefinitions, TNameField extends NameFieldDefinition> {
23
+ readonly name: LogicalCustomObjectName<TObjectName>;
24
+ readonly displayName: string;
25
+ readonly pluralLabel?: string;
26
+ readonly category: CategoryInput<TCategoryName>;
27
+ readonly ownerRole?: string;
28
+ readonly enableHistory?: boolean;
29
+ readonly description: string;
30
+ readonly icon?: {
31
+ readonly emoji?: string | null;
32
+ readonly ripplingIcon?: string | null;
33
+ readonly s3Bucket?: string;
34
+ readonly s3Key?: string;
35
+ };
36
+ readonly nameField?: TNameField;
37
+ readonly sections?: TSections;
38
+ readonly fields: ValidateFieldMap<TFields>;
39
+ }
40
+ /**
41
+ * Rejects extension objects that try to redefine keys already present on the base definition.
42
+ *
43
+ * @typeParam TExisting - Existing key set on the base definition.
44
+ * @typeParam TAdded - Proposed extension object.
45
+ */
46
+ type NoOverlappingKeys<TExisting extends object, TAdded extends object> = Extract<keyof TExisting, keyof TAdded> extends never ? TAdded : never;
47
+ /**
48
+ * Converts a logical field map into a version whose keys must all satisfy the
49
+ * logical custom-field name contract.
50
+ *
51
+ * @typeParam TFields - Candidate logical field map supplied by callers.
52
+ */
53
+ type ValidateFieldMap<TFields extends FieldDefinitions> = {
54
+ readonly [K in keyof TFields]: K extends string ? LogicalCustomFieldName<K> extends never ? never : TFields[K] : never;
55
+ };
56
+ /**
57
+ * Appends the platform-required `__c` suffix to a logical custom-object name.
58
+ *
59
+ * @param name - Logical unsuffixed custom-object name.
60
+ * @returns Wire-level custom-object API name with the required `__c` suffix.
61
+ * @typeParam TObjectName - Logical custom-object name to compile.
62
+ */
63
+ export declare function toCustomObjectApiName<TObjectName extends string>(name: LogicalCustomObjectName<TObjectName>): CustomObjectApiName<TObjectName>;
64
+ /**
65
+ * Appends the platform-required `__c` suffix to a logical custom-field name.
66
+ *
67
+ * @param name - Logical unsuffixed custom-field name.
68
+ * @returns Wire-level custom-field API name with the required `__c` suffix.
69
+ * @typeParam TFieldName - Logical custom-field name to compile.
70
+ */
71
+ export declare function toCustomFieldApiName<TFieldName extends string>(name: LogicalCustomFieldName<TFieldName>): `${TFieldName}__c`;
72
+ /**
73
+ * Appends the platform-required `__c` suffix to a logical category name.
74
+ *
75
+ * @param name - Logical unsuffixed category name.
76
+ * @returns Wire-level category API name with the required `__c` suffix.
77
+ * @typeParam TCategoryName - Logical category name to compile.
78
+ */
79
+ export declare function toCustomCategoryApiName<TCategoryName extends string>(name: LogicalCategoryName<TCategoryName>): CategoryApiName<TCategoryName>;
80
+ /**
81
+ * Defines an immutable, strongly typed custom-object schema.
82
+ *
83
+ * Callers author only logical snake_case names. The returned value includes the
84
+ * derived wire-level api names so downstream tooling can emit valid manifest
85
+ * payloads without requiring authors to know about the `__c` suffix contract.
86
+ *
87
+ * @typeParam TObjectName - Logical custom-object name for the definition.
88
+ * @typeParam TCategoryName - Logical category name associated with the object.
89
+ * @typeParam TSections - Section map available to field definitions.
90
+ * @typeParam TFields - Field map keyed by logical custom-field names.
91
+ * @param definition - Author-facing typed schema definition to normalize, validate, and freeze.
92
+ * @returns Immutable normalized custom-object definition with compiled field and object API names.
93
+ * @typeParam TNameField - Name-field behavior for the object.
94
+ */
95
+ export declare function defineCustomObject<TObjectName extends string, TCategoryName extends string, TSections extends SectionDefinitions = {}, TFields extends FieldDefinitions = FieldDefinitions, TNameField extends NameFieldDefinition = {
96
+ kind: 'text';
97
+ }>(definition: CustomObjectDefinitionInput<TObjectName, TCategoryName, TSections, TFields, TNameField>): Readonly<CustomObjectDefinition<LogicalCustomObjectName<TObjectName>, LogicalCategoryName<TCategoryName>, TSections, TFields, TNameField>>;
98
+ /**
99
+ * Extends an existing object definition without losing type information.
100
+ *
101
+ * This helper is useful when a platform package wants to publish a base schema
102
+ * and another package wants to add fields or sections in a type-safe way.
103
+ *
104
+ * @typeParam TBase - Existing object definition being extended.
105
+ * @typeParam TAddedSections - New section definitions merged into the base object.
106
+ * @param base - Existing typed object definition to extend.
107
+ * @param extension - Additional metadata, sections, and fields to merge into the base definition.
108
+ * @returns New immutable custom-object definition preserving the combined type information.
109
+ * @typeParam TAddedFields - New field definitions merged into the base object.
110
+ */
111
+ export declare function extendCustomObject<TBase extends AnyCustomObjectDefinition, TAddedSections extends SectionDefinitions = {}, TAddedFields extends FieldDefinitions = {}>(base: TBase, extension: {
112
+ readonly displayName?: string;
113
+ readonly pluralLabel?: string;
114
+ readonly ownerRole?: string;
115
+ readonly enableHistory?: boolean;
116
+ readonly description?: string;
117
+ readonly icon?: TBase['icon'];
118
+ readonly sections?: NoOverlappingKeys<TBase['sections'], TAddedSections>;
119
+ readonly fields?: NoOverlappingKeys<TBase['fields'], ValidateFieldMap<TAddedFields>>;
120
+ }): Readonly<CustomObjectDefinition<TBase['name'], TBase['category'], TBase['sections'] & TAddedSections, Omit<TBase['fields'], never> & TAddedFields, TBase['nameField']>>;
121
+ /**
122
+ * Returns the logical custom field names defined on an object.
123
+ *
124
+ * @param definition - Object definition whose logical field names should be returned.
125
+ * @returns Frozen array of logical field names from the definition.
126
+ * @typeParam TDefinition - Object definition whose field names should be returned.
127
+ */
128
+ export declare function fieldNames<TDefinition extends AnyCustomObjectDefinition>(definition: TDefinition): ReadonlyArray<FieldNames<TDefinition>>;
129
+ /**
130
+ * Retrieves a field definition by logical field name with precise typing.
131
+ *
132
+ * @param definition - Object definition that owns the field.
133
+ * @param fieldName - Logical field name to retrieve.
134
+ * @returns Precisely typed field definition for the requested logical field name.
135
+ * @typeParam TDefinition - Object definition that owns the field.
136
+ * @typeParam TFieldName - Logical field name being retrieved.
137
+ */
138
+ export declare function getFieldDefinition<TDefinition extends AnyCustomObjectDefinition, TFieldName extends FieldNames<TDefinition>>(definition: TDefinition, fieldName: TFieldName): TDefinition['fields'][TFieldName];
139
+ /**
140
+ * Returns whether one typed field definition is writable by record create/update helpers.
141
+ *
142
+ * @param field - Typed field definition to inspect.
143
+ * @returns Whether the field may be written by callers.
144
+ */
145
+ export declare function isWritableField(field: AnyFieldDefinition): boolean;
146
+ export {};
147
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/core/platform/custom-objects/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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AMG;AACH,wBAAgB,UAAU,CAAC,WAAW,SAAS,yBAAyB,EACtE,UAAU,EAAE,WAAW,GACtB,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAExC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,SAAS,yBAAyB,EAC7C,UAAU,SAAS,UAAU,CAAC,WAAW,CAAC,EAC1C,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAEnF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAElE"}
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCustomObjectApiName = toCustomObjectApiName;
4
+ exports.toCustomFieldApiName = toCustomFieldApiName;
5
+ exports.toCustomCategoryApiName = toCustomCategoryApiName;
6
+ exports.defineCustomObject = defineCustomObject;
7
+ exports.extendCustomObject = extendCustomObject;
8
+ exports.fieldNames = fieldNames;
9
+ exports.getFieldDefinition = getFieldDefinition;
10
+ exports.isWritableField = isWritableField;
11
+ const validation_1 = require("./validation.js");
12
+ /**
13
+ * Recursively freezes author-authored schema definitions.
14
+ *
15
+ * The schema layer is intended to act like durable configuration data rather
16
+ * than mutable runtime state, so this helper aggressively removes mutation as a
17
+ * failure mode after validation succeeds.
18
+ *
19
+ * @typeParam T - Value being frozen.
20
+ */
21
+ /**
22
+ * Deeply freezes a schema fragment after validation succeeds.
23
+ *
24
+ * @param value - Value to recursively freeze in place.
25
+ * @returns The same value, now deeply frozen where applicable.
26
+ * @typeParam T - Value being frozen.
27
+ */
28
+ function deepFreeze(value) {
29
+ if (value == null || typeof value !== 'object')
30
+ return value;
31
+ for (const child of Object.values(value)) {
32
+ deepFreeze(child);
33
+ }
34
+ return Object.freeze(value);
35
+ }
36
+ /**
37
+ * Appends the platform-required `__c` suffix to a logical custom-object name.
38
+ *
39
+ * @param name - Logical unsuffixed custom-object name.
40
+ * @returns Wire-level custom-object API name with the required `__c` suffix.
41
+ * @typeParam TObjectName - Logical custom-object name to compile.
42
+ */
43
+ function toCustomObjectApiName(name) {
44
+ return `${name}__c`;
45
+ }
46
+ /**
47
+ * Appends the platform-required `__c` suffix to a logical custom-field name.
48
+ *
49
+ * @param name - Logical unsuffixed custom-field name.
50
+ * @returns Wire-level custom-field API name with the required `__c` suffix.
51
+ * @typeParam TFieldName - Logical custom-field name to compile.
52
+ */
53
+ function toCustomFieldApiName(name) {
54
+ return `${name}__c`;
55
+ }
56
+ /**
57
+ * Appends the platform-required `__c` suffix to a logical category name.
58
+ *
59
+ * @param name - Logical unsuffixed category name.
60
+ * @returns Wire-level category API name with the required `__c` suffix.
61
+ * @typeParam TCategoryName - Logical category name to compile.
62
+ */
63
+ function toCustomCategoryApiName(name) {
64
+ return `${name}__c`;
65
+ }
66
+ /**
67
+ * Defines an immutable, strongly typed custom-object schema.
68
+ *
69
+ * Callers author only logical snake_case names. The returned value includes the
70
+ * derived wire-level api names so downstream tooling can emit valid manifest
71
+ * payloads without requiring authors to know about the `__c` suffix contract.
72
+ *
73
+ * @typeParam TObjectName - Logical custom-object name for the definition.
74
+ * @typeParam TCategoryName - Logical category name associated with the object.
75
+ * @typeParam TSections - Section map available to field definitions.
76
+ * @typeParam TFields - Field map keyed by logical custom-field names.
77
+ * @param definition - Author-facing typed schema definition to normalize, validate, and freeze.
78
+ * @returns Immutable normalized custom-object definition with compiled field and object API names.
79
+ * @typeParam TNameField - Name-field behavior for the object.
80
+ */
81
+ function defineCustomObject(definition) {
82
+ (0, validation_1.validateLogicalCustomObjectName)(definition.name);
83
+ const categoryDefinition = typeof definition.category === 'string' ? undefined : definition.category;
84
+ const categoryName = typeof definition.category === 'string' ? definition.category : definition.category.name;
85
+ const categoryApiName = typeof definition.category === 'string' ?
86
+ toCustomCategoryApiName(definition.category)
87
+ : definition.category.apiName;
88
+ (0, validation_1.validateLogicalCategoryName)(categoryName);
89
+ const resolvedFields = Object.fromEntries(Object.entries(definition.fields).map(([logicalName, field]) => {
90
+ (0, validation_1.validateLogicalCustomFieldName)(logicalName);
91
+ return [
92
+ logicalName,
93
+ {
94
+ ...field,
95
+ logicalName,
96
+ apiName: toCustomFieldApiName(logicalName),
97
+ },
98
+ ];
99
+ }));
100
+ const normalized = {
101
+ name: definition.name,
102
+ apiName: toCustomObjectApiName(definition.name),
103
+ displayName: definition.displayName,
104
+ ...(definition.pluralLabel != null ? { pluralLabel: definition.pluralLabel } : {}),
105
+ category: categoryName,
106
+ ...(categoryDefinition != null ? { categoryDefinition } : {}),
107
+ ...(definition.ownerRole != null ? { ownerRole: definition.ownerRole } : {}),
108
+ ...(definition.enableHistory != null ? { enableHistory: definition.enableHistory } : {}),
109
+ categoryApiName: categoryApiName,
110
+ description: definition.description,
111
+ ...(definition.icon != null ? { icon: definition.icon } : {}),
112
+ nameField: (definition.nameField ?? { kind: 'text' }),
113
+ sections: (definition.sections ?? {}),
114
+ fields: resolvedFields,
115
+ };
116
+ const issues = (0, validation_1.validateCustomObjectDefinition)(normalized);
117
+ if (issues.length > 0) {
118
+ throw new Error(`Invalid custom object definition for "${definition.name}":\n` +
119
+ issues.map((issue) => `- ${issue.path}: ${issue.message}`).join('\n'));
120
+ }
121
+ return deepFreeze(normalized);
122
+ }
123
+ /**
124
+ * Extends an existing object definition without losing type information.
125
+ *
126
+ * This helper is useful when a platform package wants to publish a base schema
127
+ * and another package wants to add fields or sections in a type-safe way.
128
+ *
129
+ * @typeParam TBase - Existing object definition being extended.
130
+ * @typeParam TAddedSections - New section definitions merged into the base object.
131
+ * @param base - Existing typed object definition to extend.
132
+ * @param extension - Additional metadata, sections, and fields to merge into the base definition.
133
+ * @returns New immutable custom-object definition preserving the combined type information.
134
+ * @typeParam TAddedFields - New field definitions merged into the base object.
135
+ */
136
+ function extendCustomObject(base, extension) {
137
+ const mergedSections = {
138
+ ...base.sections,
139
+ ...(extension.sections ?? {}),
140
+ };
141
+ const mergedFields = Object.fromEntries(Object.entries({ ...base.fields, ...(extension.fields ?? {}) }).map(([logicalName, field]) => [
142
+ logicalName,
143
+ {
144
+ ...field,
145
+ logicalName,
146
+ apiName: toCustomFieldApiName(logicalName),
147
+ },
148
+ ]));
149
+ return defineCustomObject({
150
+ name: base.name,
151
+ displayName: extension.displayName ?? base.displayName,
152
+ ...(extension.pluralLabel != null || base.pluralLabel != null ?
153
+ { pluralLabel: extension.pluralLabel ?? base.pluralLabel }
154
+ : {}),
155
+ ...(extension.ownerRole != null || base.ownerRole != null ?
156
+ { ownerRole: extension.ownerRole ?? base.ownerRole }
157
+ : {}),
158
+ ...(extension.enableHistory != null || base.enableHistory != null ?
159
+ { enableHistory: extension.enableHistory ?? base.enableHistory }
160
+ : {}),
161
+ category: base.categoryDefinition ?? base.category,
162
+ description: extension.description ?? base.description,
163
+ ...((extension.icon ?? base.icon) != null ? { icon: extension.icon ?? base.icon } : {}),
164
+ nameField: base.nameField,
165
+ sections: mergedSections,
166
+ fields: mergedFields,
167
+ });
168
+ }
169
+ /**
170
+ * Returns the logical custom field names defined on an object.
171
+ *
172
+ * @param definition - Object definition whose logical field names should be returned.
173
+ * @returns Frozen array of logical field names from the definition.
174
+ * @typeParam TDefinition - Object definition whose field names should be returned.
175
+ */
176
+ function fieldNames(definition) {
177
+ return Object.freeze(Object.keys(definition.fields));
178
+ }
179
+ /**
180
+ * Retrieves a field definition by logical field name with precise typing.
181
+ *
182
+ * @param definition - Object definition that owns the field.
183
+ * @param fieldName - Logical field name to retrieve.
184
+ * @returns Precisely typed field definition for the requested logical field name.
185
+ * @typeParam TDefinition - Object definition that owns the field.
186
+ * @typeParam TFieldName - Logical field name being retrieved.
187
+ */
188
+ function getFieldDefinition(definition, fieldName) {
189
+ return definition.fields[fieldName];
190
+ }
191
+ /**
192
+ * Returns whether one typed field definition is writable by record create/update helpers.
193
+ *
194
+ * @param field - Typed field definition to inspect.
195
+ * @returns Whether the field may be written by callers.
196
+ */
197
+ function isWritableField(field) {
198
+ return field.writable;
199
+ }
200
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/core/platform/custom-objects/definition.ts"],"names":[],"mappings":";;AAkIA,sDAIC;AASD,oDAIC;AASD,0DAIC;AAiBD,gDAiFC;AAeD,gDA4DC;AASD,gCAIC;AAWD,gDAKC;AAQD,0CAEC;AApWD,gDAKsB;AA4EtB;;;;;;;;GAQG;AACH;;;;;;GAMG;AACH,SAAS,UAAU,CAAI,KAAQ;IAC7B,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE7D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAgC,CAAC,EAAE,CAAC;QACpE,UAAU,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,IAA0C;IAE1C,OAAO,GAAG,IAAI,KAAyC,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,IAAwC;IAExC,OAAO,GAAG,IAAI,KAAK,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,IAAwC;IAExC,OAAO,GAAG,IAAI,KAAuC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,kBAAkB,CAOhC,UAAmG;IAUnG,IAAA,4CAA+B,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjD,MAAM,kBAAkB,GAAG,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;IACrG,MAAM,YAAY,GAChB,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