@rippling/rippling-sdk 0.2.0-alpha.35 → 0.2.0-alpha.37

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 (149) hide show
  1. package/client.d.mts +13 -1
  2. package/client.d.mts.map +1 -1
  3. package/client.d.ts +13 -1
  4. package/client.d.ts.map +1 -1
  5. package/client.js +13 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +13 -1
  8. package/client.mjs.map +1 -1
  9. package/examples/.keep +4 -0
  10. package/examples/manifest/dental-practice-management/dental-practice-management.ts +638 -0
  11. package/examples/manifest/dental-practice-management/manifest.json +1870 -0
  12. package/examples/manifest/gym-membership-management/gym-membership-management.ts +746 -0
  13. package/examples/manifest/gym-membership-management/manifest.json +1975 -0
  14. package/examples/sdui/sdui-crud-todo/rippling-function.ts +367 -0
  15. package/examples/sdui/sdui-crud-todo/sdui-crud-todo.ts +282 -0
  16. package/examples/sdui/sdui-showcase/rippling-function.ts +381 -0
  17. package/examples/sdui/sdui-showcase/sdui-showcase.ts +351 -0
  18. package/examples/sdui/sdui-tab-multi-view/rippling-function.ts +1061 -0
  19. package/examples/sdui/sdui-tab-multi-view/sdui-tab-multi-view.ts +924 -0
  20. package/examples/sdui/vote/rippling-function.ts +330 -0
  21. package/examples/sdui/vote/vote.ts +298 -0
  22. package/internal/utils/log.d.mts.map +1 -1
  23. package/internal/utils/log.d.ts.map +1 -1
  24. package/internal/utils/log.js +2 -0
  25. package/internal/utils/log.js.map +1 -1
  26. package/internal/utils/log.mjs +2 -0
  27. package/internal/utils/log.mjs.map +1 -1
  28. package/lib/manifest/custom-object-field-section.d.mts +4 -0
  29. package/lib/manifest/custom-object-field-section.d.mts.map +1 -1
  30. package/lib/manifest/custom-object-field-section.d.ts +4 -0
  31. package/lib/manifest/custom-object-field-section.d.ts.map +1 -1
  32. package/lib/manifest/custom-object-field-section.js +6 -0
  33. package/lib/manifest/custom-object-field-section.js.map +1 -1
  34. package/lib/manifest/custom-object-field-section.mjs +6 -0
  35. package/lib/manifest/custom-object-field-section.mjs.map +1 -1
  36. package/lib/manifest/custom-object-page-layout.d.mts +21 -13
  37. package/lib/manifest/custom-object-page-layout.d.mts.map +1 -1
  38. package/lib/manifest/custom-object-page-layout.d.ts +21 -13
  39. package/lib/manifest/custom-object-page-layout.d.ts.map +1 -1
  40. package/lib/manifest/custom-object-page-layout.js +119 -9
  41. package/lib/manifest/custom-object-page-layout.js.map +1 -1
  42. package/lib/manifest/custom-object-page-layout.mjs +119 -9
  43. package/lib/manifest/custom-object-page-layout.mjs.map +1 -1
  44. package/lib/manifest/field.d.mts +5 -1
  45. package/lib/manifest/field.d.mts.map +1 -1
  46. package/lib/manifest/field.d.ts +5 -1
  47. package/lib/manifest/field.d.ts.map +1 -1
  48. package/lib/manifest/field.js +8 -0
  49. package/lib/manifest/field.js.map +1 -1
  50. package/lib/manifest/field.mjs +8 -0
  51. package/lib/manifest/field.mjs.map +1 -1
  52. package/lib/manifest/index.d.mts +1 -1
  53. package/lib/manifest/index.d.mts.map +1 -1
  54. package/lib/manifest/index.d.ts +1 -1
  55. package/lib/manifest/index.d.ts.map +1 -1
  56. package/lib/manifest/index.js.map +1 -1
  57. package/lib/manifest/index.mjs.map +1 -1
  58. package/package.json +11 -1
  59. package/resources/company-legal-entities.d.mts +180 -0
  60. package/resources/company-legal-entities.d.mts.map +1 -0
  61. package/resources/company-legal-entities.d.ts +180 -0
  62. package/resources/company-legal-entities.d.ts.map +1 -0
  63. package/resources/company-legal-entities.js +30 -0
  64. package/resources/company-legal-entities.js.map +1 -0
  65. package/resources/company-legal-entities.mjs +26 -0
  66. package/resources/company-legal-entities.mjs.map +1 -0
  67. package/resources/company-legal-entity-workers.d.mts +79 -0
  68. package/resources/company-legal-entity-workers.d.mts.map +1 -0
  69. package/resources/company-legal-entity-workers.d.ts +79 -0
  70. package/resources/company-legal-entity-workers.d.ts.map +1 -0
  71. package/resources/company-legal-entity-workers.js +30 -0
  72. package/resources/company-legal-entity-workers.js.map +1 -0
  73. package/resources/company-legal-entity-workers.mjs +26 -0
  74. package/resources/company-legal-entity-workers.mjs.map +1 -0
  75. package/resources/earning-types.d.mts +1 -6
  76. package/resources/earning-types.d.mts.map +1 -1
  77. package/resources/earning-types.d.ts +1 -6
  78. package/resources/earning-types.d.ts.map +1 -1
  79. package/resources/earning-types.js +1 -1
  80. package/resources/earning-types.mjs +1 -1
  81. package/resources/earnings-inputs.d.mts +1 -1
  82. package/resources/earnings-inputs.d.ts +1 -1
  83. package/resources/earnings-inputs.js +1 -1
  84. package/resources/earnings-inputs.mjs +1 -1
  85. package/resources/index.d.mts +3 -1
  86. package/resources/index.d.mts.map +1 -1
  87. package/resources/index.d.ts +3 -1
  88. package/resources/index.d.ts.map +1 -1
  89. package/resources/index.js +7 -3
  90. package/resources/index.js.map +1 -1
  91. package/resources/index.mjs +3 -1
  92. package/resources/index.mjs.map +1 -1
  93. package/resources/legal-entities.d.mts +1 -1
  94. package/resources/legal-entities.d.mts.map +1 -1
  95. package/resources/legal-entities.d.ts +1 -1
  96. package/resources/legal-entities.d.ts.map +1 -1
  97. package/resources/payroll-runs/index.d.mts +3 -0
  98. package/resources/payroll-runs/index.d.mts.map +1 -0
  99. package/resources/payroll-runs/index.d.ts +3 -0
  100. package/resources/payroll-runs/index.d.ts.map +1 -0
  101. package/resources/payroll-runs/index.js +9 -0
  102. package/resources/payroll-runs/index.js.map +1 -0
  103. package/resources/payroll-runs/index.mjs +4 -0
  104. package/resources/payroll-runs/index.mjs.map +1 -0
  105. package/resources/payroll-runs/payroll-runs.d.mts +199 -0
  106. package/resources/payroll-runs/payroll-runs.d.mts.map +1 -0
  107. package/resources/payroll-runs/payroll-runs.d.ts +199 -0
  108. package/resources/payroll-runs/payroll-runs.d.ts.map +1 -0
  109. package/resources/payroll-runs/payroll-runs.js +40 -0
  110. package/resources/payroll-runs/payroll-runs.js.map +1 -0
  111. package/resources/payroll-runs/payroll-runs.mjs +35 -0
  112. package/resources/payroll-runs/payroll-runs.mjs.map +1 -0
  113. package/resources/payroll-runs/worker-payroll-records.d.mts +200 -0
  114. package/resources/payroll-runs/worker-payroll-records.d.mts.map +1 -0
  115. package/resources/payroll-runs/worker-payroll-records.d.ts +200 -0
  116. package/resources/payroll-runs/worker-payroll-records.d.ts.map +1 -0
  117. package/resources/payroll-runs/worker-payroll-records.js +23 -0
  118. package/resources/payroll-runs/worker-payroll-records.js.map +1 -0
  119. package/resources/payroll-runs/worker-payroll-records.mjs +19 -0
  120. package/resources/payroll-runs/worker-payroll-records.mjs.map +1 -0
  121. package/resources/payroll-runs.d.mts +1 -194
  122. package/resources/payroll-runs.d.mts.map +1 -1
  123. package/resources/payroll-runs.d.ts +1 -194
  124. package/resources/payroll-runs.d.ts.map +1 -1
  125. package/resources/payroll-runs.js +2 -28
  126. package/resources/payroll-runs.js.map +1 -1
  127. package/resources/payroll-runs.mjs +1 -26
  128. package/resources/payroll-runs.mjs.map +1 -1
  129. package/src/client.ts +47 -7
  130. package/src/internal/utils/log.ts +2 -0
  131. package/src/lib/manifest/custom-object-field-section.ts +7 -0
  132. package/src/lib/manifest/custom-object-page-layout.ts +220 -18
  133. package/src/lib/manifest/field.ts +9 -1
  134. package/src/lib/manifest/index.ts +2 -0
  135. package/src/resources/company-legal-entities.ts +237 -0
  136. package/src/resources/company-legal-entity-workers.ts +115 -0
  137. package/src/resources/earning-types.ts +1 -7
  138. package/src/resources/earnings-inputs.ts +1 -1
  139. package/src/resources/index.ts +15 -1
  140. package/src/resources/legal-entities.ts +1 -1
  141. package/src/resources/payroll-runs/index.ts +15 -0
  142. package/src/resources/payroll-runs/payroll-runs.ts +270 -0
  143. package/src/resources/payroll-runs/worker-payroll-records.ts +255 -0
  144. package/src/resources/payroll-runs.ts +1 -249
  145. package/src/version.ts +1 -1
  146. package/version.d.mts +1 -1
  147. package/version.d.ts +1 -1
  148. package/version.js +1 -1
  149. package/version.mjs +1 -1
@@ -1,4 +1,5 @@
1
1
  import { generateId } from './_helpers';
2
+ import { CustomObjectFieldSection } from './custom-object-field-section';
2
3
  import type { CustomObject } from './custom-object';
3
4
  import type { Field } from './field';
4
5
 
@@ -65,10 +66,8 @@ export interface HeaderEdits {
65
66
  // tab_edits — TabEditsDTO + section/tab DTOs
66
67
  // ---------------------------------------------------------------------------
67
68
 
68
- /** One field entry inside a `fields_section`. */
69
- export interface SectionField {
70
- /** RQL name of the field to display. Required. */
71
- fieldRqlName: string;
69
+ /** Options for one field entry inside a `fields_section`. */
70
+ export interface SectionFieldOptions {
72
71
  /** Hide this field from view. Optional. */
73
72
  hidden?: boolean;
74
73
  /** Allow inline editing of this field. Optional. */
@@ -77,13 +76,24 @@ export interface SectionField {
77
76
  movementOption?: 'tab' | 'free';
78
77
  }
79
78
 
79
+ /** A typed field entry inside a `fields_section`. */
80
+ export interface SectionFieldRef extends SectionFieldOptions {
81
+ /** Field to display. Required. */
82
+ field: Field;
83
+ }
84
+
85
+ /** One field entry inside a `fields_section`. */
86
+ export type SectionField = Field | SectionFieldRef;
87
+
80
88
  /** A standard field-grid section inside a tab. */
81
89
  export interface FieldsSection {
82
90
  type: 'fields_section';
83
- /** Stable key for this section. Required. */
84
- key: string;
85
- /** Display name of the section. Required. */
86
- name: string;
91
+ /** Field section metadata for the fields displayed in this layout section. Required. */
92
+ section: CustomObjectFieldSection;
93
+ /** Stable layout key for this section. Optional. Defaults to the field section id. */
94
+ key?: string;
95
+ /** Display name of the layout section. Optional. Defaults to the field section name. */
96
+ name?: string;
87
97
  /** Fields to display in this section. Required. */
88
98
  fields: SectionField[];
89
99
  }
@@ -255,6 +265,194 @@ export interface CustomObjectPageLayoutProps {
255
265
  blueprintKey?: string;
256
266
  }
257
267
 
268
+ interface SerializedSectionField extends SectionFieldOptions {
269
+ fieldRqlName: string;
270
+ }
271
+
272
+ interface SerializedFieldsSection {
273
+ type: 'fields_section';
274
+ key: string;
275
+ name: string;
276
+ fields: SerializedSectionField[];
277
+ }
278
+
279
+ interface SerializedTabWithSections {
280
+ type: 'tab_with_sections';
281
+ key: string;
282
+ name: string;
283
+ sections: SerializedFieldsSection[];
284
+ }
285
+
286
+ type SerializedPageLayoutTab = SerializedTabWithSections | CustomTab;
287
+
288
+ interface SerializedSystemSectionEdit extends Omit<SystemSectionEdit, 'newFields'> {
289
+ newFields?: SerializedSectionField[];
290
+ }
291
+
292
+ interface SerializedSystemTabEdit extends Omit<SystemTabEdit, 'newSections' | 'systemSectionEdits'> {
293
+ newSections?: SerializedFieldsSection[];
294
+ systemSectionEdits?: Record<string, SerializedSystemSectionEdit>;
295
+ }
296
+
297
+ interface SerializedTabEdits extends Omit<TabEdits, 'newTabs' | 'systemTabEdits'> {
298
+ newTabs?: SerializedPageLayoutTab[];
299
+ systemTabEdits?: Record<string, SerializedSystemTabEdit>;
300
+ }
301
+
302
+ function isField(value: unknown): value is Field {
303
+ const candidate = value as {
304
+ getApiName?: unknown;
305
+ getCustomObjectApiName?: unknown;
306
+ getSectionId?: unknown;
307
+ _assignSection?: unknown;
308
+ } | null;
309
+ return (
310
+ candidate != null &&
311
+ typeof candidate.getApiName === 'function' &&
312
+ typeof candidate.getCustomObjectApiName === 'function' &&
313
+ typeof candidate.getSectionId === 'function' &&
314
+ typeof candidate._assignSection === 'function'
315
+ );
316
+ }
317
+
318
+ function isFieldRef(value: SectionField): value is SectionFieldRef {
319
+ const candidate = value as { field?: unknown } | null;
320
+ return candidate != null && typeof candidate === 'object' && isField(candidate.field);
321
+ }
322
+
323
+ function assertSameObject(customObject: CustomObject, field: Field, sectionKey: string): void {
324
+ if (field.getCustomObjectApiName() !== customObject.getApiName()) {
325
+ throw new Error(
326
+ `CustomObjectPageLayout fields_section "${sectionKey}" references field "${field.getApiName()}" ` +
327
+ `from "${field.getCustomObjectApiName()}", but the layout belongs to "${customObject.getApiName()}".`,
328
+ );
329
+ }
330
+ }
331
+
332
+ function assertSectionBelongsTo(customObject: CustomObject, section: CustomObjectFieldSection): void {
333
+ if (section.getModelApiName() !== customObject.getApiName()) {
334
+ throw new Error(
335
+ `CustomObjectPageLayout section "${section.getSectionId()}" belongs to "${section.getModelApiName()}", ` +
336
+ `but the layout belongs to "${customObject.getApiName()}".`,
337
+ );
338
+ }
339
+ }
340
+
341
+ function toSerializedSectionField(
342
+ fieldRqlName: string,
343
+ options: SectionFieldOptions = {},
344
+ ): SerializedSectionField {
345
+ const normalized: SerializedSectionField = { fieldRqlName };
346
+ if (options.hidden != null) normalized.hidden = options.hidden;
347
+ if (options.editable != null) normalized.editable = options.editable;
348
+ if (options.movementOption != null) normalized.movementOption = options.movementOption;
349
+ return normalized;
350
+ }
351
+
352
+ function normalizeSectionField(
353
+ customObject: CustomObject,
354
+ section: CustomObjectFieldSection | string,
355
+ sectionKey: string,
356
+ entry: SectionField,
357
+ ): SerializedSectionField {
358
+ if (isField(entry)) {
359
+ assertSameObject(customObject, entry, sectionKey);
360
+ entry._assignSection(section);
361
+ return toSerializedSectionField(entry.getApiName());
362
+ }
363
+
364
+ if (isFieldRef(entry)) {
365
+ assertSameObject(customObject, entry.field, sectionKey);
366
+ entry.field._assignSection(section);
367
+ return toSerializedSectionField(entry.field.getApiName(), entry);
368
+ }
369
+
370
+ throw new Error(
371
+ `CustomObjectPageLayout fields_section "${sectionKey}" has an invalid field entry; ` +
372
+ 'pass a Field instance or { field }.',
373
+ );
374
+ }
375
+
376
+ function normalizeFieldsSection(
377
+ customObject: CustomObject,
378
+ input: PageLayoutSection,
379
+ ): SerializedFieldsSection {
380
+ assertSectionBelongsTo(customObject, input.section);
381
+ const key = input.key ?? input.section.getSectionId();
382
+ const name = input.name ?? input.section.getName();
383
+ return {
384
+ key,
385
+ name,
386
+ type: 'fields_section',
387
+ fields: input.fields.map((field) => normalizeSectionField(customObject, input.section, key, field)),
388
+ };
389
+ }
390
+
391
+ function normalizeTab(customObject: CustomObject, tab: PageLayoutTab): SerializedPageLayoutTab {
392
+ if (tab.type === 'custom_tab') return tab;
393
+ return {
394
+ ...tab,
395
+ sections: tab.sections.map((section) => normalizeFieldsSection(customObject, section)),
396
+ };
397
+ }
398
+
399
+ function normalizeSystemSectionEdit(
400
+ customObject: CustomObject,
401
+ tabKey: string,
402
+ sectionKey: string,
403
+ edit: SystemSectionEdit,
404
+ ): SerializedSystemSectionEdit {
405
+ const { newFields: _newFields, ...rest } = edit;
406
+ const normalized: SerializedSystemSectionEdit = { ...rest };
407
+ if (edit.newFields != null) {
408
+ normalized.newFields = edit.newFields.map((field) =>
409
+ normalizeSectionField(customObject, sectionKey, `${tabKey}.${sectionKey}`, field),
410
+ );
411
+ }
412
+ return normalized;
413
+ }
414
+
415
+ function normalizeSystemTabEdit(
416
+ customObject: CustomObject,
417
+ tabKey: string,
418
+ edit: SystemTabEdit,
419
+ ): SerializedSystemTabEdit {
420
+ const { newSections: _newSections, systemSectionEdits: _systemSectionEdits, ...rest } = edit;
421
+ const normalized: SerializedSystemTabEdit = { ...rest };
422
+ if (edit.newSections != null) {
423
+ normalized.newSections = edit.newSections.map((section) => normalizeFieldsSection(customObject, section));
424
+ }
425
+ if (edit.systemSectionEdits != null) {
426
+ const systemSectionEdits: Record<string, SerializedSystemSectionEdit> = {};
427
+ for (const [sectionKey, sectionEdit] of Object.entries(edit.systemSectionEdits)) {
428
+ systemSectionEdits[sectionKey] = normalizeSystemSectionEdit(
429
+ customObject,
430
+ tabKey,
431
+ sectionKey,
432
+ sectionEdit,
433
+ );
434
+ }
435
+ normalized.systemSectionEdits = systemSectionEdits;
436
+ }
437
+ return normalized;
438
+ }
439
+
440
+ function normalizeTabEdits(customObject: CustomObject, tabEdits: TabEdits): SerializedTabEdits {
441
+ const { newTabs: _newTabs, systemTabEdits: _systemTabEdits, ...rest } = tabEdits;
442
+ const normalized: SerializedTabEdits = { ...rest };
443
+ if (tabEdits.newTabs != null) {
444
+ normalized.newTabs = tabEdits.newTabs.map((tab) => normalizeTab(customObject, tab));
445
+ }
446
+ if (tabEdits.systemTabEdits != null) {
447
+ const systemTabEdits: Record<string, SerializedSystemTabEdit> = {};
448
+ for (const [tabKey, tabEdit] of Object.entries(tabEdits.systemTabEdits)) {
449
+ systemTabEdits[tabKey] = normalizeSystemTabEdit(customObject, tabKey, tabEdit);
450
+ }
451
+ normalized.systemTabEdits = systemTabEdits;
452
+ }
453
+ return normalized;
454
+ }
455
+
258
456
  // ---------------------------------------------------------------------------
259
457
  // Class
260
458
  // ---------------------------------------------------------------------------
@@ -283,11 +481,11 @@ export interface CustomObjectPageLayoutProps {
283
481
  * newTabs: [{
284
482
  * key: 'member', name: 'Member', type: 'tab_with_sections',
285
483
  * sections: [{
286
- * key: 'profile', name: 'Profile', type: 'fields_section',
287
- * fields: [
288
- * { fieldRqlName: memberFirstName.getApiName() },
289
- * { fieldRqlName: memberEmail.getApiName() },
290
- * ],
484
+ * key: 'profile',
485
+ * name: 'Profile',
486
+ * type: 'fields_section',
487
+ * section: profileSection,
488
+ * fields: [memberFirstName, memberEmail],
291
489
  * }],
292
490
  * }],
293
491
  * systemTabEdits: {},
@@ -304,7 +502,7 @@ export class CustomObjectPageLayout {
304
502
  private readonly _apiName: string;
305
503
  private readonly _customObjectApiName: string;
306
504
  private readonly _name: string;
307
- private readonly _tabEdits: TabEdits;
505
+ private readonly _tabEdits: SerializedTabEdits;
308
506
  private readonly _headerEdits: HeaderEdits;
309
507
  private readonly _visibilityConditions: VisibilityConditions;
310
508
  private readonly _blueprintKey: string | undefined;
@@ -321,7 +519,7 @@ export class CustomObjectPageLayout {
321
519
  this._apiName = props.apiName;
322
520
  this._customObjectApiName = customObject.getApiName();
323
521
  this._name = props.name;
324
- this._tabEdits = props.tabEdits ?? {};
522
+ this._tabEdits = normalizeTabEdits(customObject, props.tabEdits ?? {});
325
523
  this._headerEdits = props.headerEdits ?? {};
326
524
  this._visibilityConditions = props.visibilityConditions ?? {};
327
525
  this._blueprintKey = props.blueprintKey;
@@ -396,6 +594,11 @@ export class CustomObjectPageLayout {
396
594
  ): CustomObjectPageLayout {
397
595
  const coApiName = customObject.getApiName();
398
596
  const coName = customObject.getName();
597
+ const sectionPrefix = coApiName.replace(/__c$/, '').replace(/[^a-zA-Z0-9]+/g, '_');
598
+ const generalSection = new CustomObjectFieldSection(customObject, {
599
+ sectionId: `sec_${sectionPrefix}_general`,
600
+ name: 'General',
601
+ });
399
602
  return new CustomObjectPageLayout(customObject, {
400
603
  apiName: 'default',
401
604
  name: `${coName} Layout`,
@@ -410,9 +613,8 @@ export class CustomObjectPageLayout {
410
613
  key: 'general',
411
614
  name: 'General',
412
615
  type: 'fields_section',
413
- fields: (props.fields ?? []).map((f: Field) => ({
414
- fieldRqlName: f.getApiName(),
415
- })),
616
+ section: generalSection,
617
+ fields: props.fields ?? [],
416
618
  },
417
619
  ],
418
620
  },
@@ -130,7 +130,7 @@ export class Field {
130
130
  private readonly _rqlFormula: string | null;
131
131
  private readonly _formulaAttrMetas: Record<string, any> | null;
132
132
  private readonly _derivedFieldFormula: string | null;
133
- private readonly _section: string | null;
133
+ private _section: string | null;
134
134
  private readonly _summarySpec: SummarySpec | null;
135
135
  private readonly _derivedAggregatedFieldStatic: Record<string, any> | null;
136
136
 
@@ -202,6 +202,14 @@ export class Field {
202
202
  isSummary(): boolean {
203
203
  return this._summarySpec != null;
204
204
  }
205
+ /** Returns the field section id assigned to this field, if any. */
206
+ getSectionId(): string | null {
207
+ return this._section;
208
+ }
209
+ /** @internal Assigns this field to a field section during page-layout normalization. */
210
+ _assignSection(section: CustomObjectFieldSection | string): void {
211
+ this._section = typeof section === 'string' ? section : section.getSectionId();
212
+ }
205
213
 
206
214
  // ── Serialization ──────────────────────────────────────────────────────
207
215
 
@@ -35,6 +35,8 @@ export {
35
35
  type PageLayoutSection,
36
36
  type PageLayoutTab,
37
37
  type SectionField,
38
+ type SectionFieldOptions,
39
+ type SectionFieldRef,
38
40
  type SectionFieldsLayout,
39
41
  type SystemHeaderFieldEdit,
40
42
  type SystemSectionEdit,
@@ -0,0 +1,237 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as BusinessPartnersAPI from './business-partners';
5
+ import * as Shared from './shared';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { PageCursorURL, PagePromise } from '../core/pagination';
8
+ import { RequestOptions } from '../internal/request-options';
9
+ import { path } from '../internal/utils/path';
10
+
11
+ /**
12
+ * Legal entities registered by the company
13
+ */
14
+ export class CompanyLegalEntities extends APIResource {
15
+ /**
16
+ * A list of company legal entities.
17
+ *
18
+ * - Requires: `API Tier 2`
19
+ * - Filterable fields: `country_code`
20
+ * - Sortable fields: `id`, `created_at`, `updated_at`
21
+ */
22
+ list(
23
+ query: CompanyLegalEntityListParams | null | undefined = {},
24
+ options?: RequestOptions,
25
+ ): PagePromise<CompanyLegalEntityListResponsesPageCursorURL, CompanyLegalEntityListResponse> {
26
+ return this._client.getAPIList(
27
+ '/company-legal-entities/',
28
+ PageCursorURL<CompanyLegalEntityListResponse>,
29
+ { query, ...options },
30
+ );
31
+ }
32
+
33
+ /**
34
+ * Retrieve a specific company legal entity
35
+ */
36
+ retrieve(id: string, options?: RequestOptions): APIPromise<CompanyLegalEntityRetrieveResponse> {
37
+ return this._client.get(path`/company-legal-entities/${id}/`, options);
38
+ }
39
+ }
40
+
41
+ export type CompanyLegalEntityListResponsesPageCursorURL = PageCursorURL<CompanyLegalEntityListResponse>;
42
+
43
+ export interface CompanyLegalEntityListResponse {
44
+ /**
45
+ * Identifier field
46
+ */
47
+ id: string;
48
+
49
+ /**
50
+ * Record creation date
51
+ */
52
+ created_at: string;
53
+
54
+ /**
55
+ * Record update date
56
+ */
57
+ updated_at: string;
58
+
59
+ /**
60
+ * The company associated with this entity relationship.
61
+ */
62
+ company_id?: string;
63
+
64
+ /**
65
+ * The ISO country code for the entity.
66
+ */
67
+ country_code?: string;
68
+
69
+ /**
70
+ * The entity's level in a hierarchy. _ `PARENT`: The legal entity is considered
71
+ * the ultimate holding entity. _ `SUBSIDIARY`: The legal entity is considered a
72
+ * subsidiary, fully or partially held by another. \* `BRANCH`: The legal entity is
73
+ * considered a branch, associated with a parent legal entity.
74
+ */
75
+ entity_level?: 'PARENT' | 'SUBSIDIARY' | 'BRANCH';
76
+
77
+ /**
78
+ * True if this entity relationship has been archived.
79
+ */
80
+ is_archived?: boolean;
81
+
82
+ /**
83
+ * True if this entity is managed as a Contractor of Record.
84
+ */
85
+ is_cor?: boolean;
86
+
87
+ /**
88
+ * True if this entity is managed as an Employer of Record.
89
+ */
90
+ is_eor?: boolean;
91
+
92
+ /**
93
+ * True if this entity is managed as a Professional Employment Organization.
94
+ */
95
+ is_peo?: boolean;
96
+
97
+ /**
98
+ * The legal name of the entity.
99
+ */
100
+ legal_name?: string;
101
+
102
+ /**
103
+ * The mailing address of the entity.
104
+ */
105
+ mailing_address?: Shared.Address;
106
+
107
+ /**
108
+ * The entity management type. _ `EOR`: The entity is managed as an Employer of
109
+ * Record. _ `COR`: The entity is managed as a Contractor of Record. _ `PEO`: The
110
+ * entity is managed as a Professional Employment Organization. _ `null`: The
111
+ * entity is a direct hire with no managed employment type.
112
+ */
113
+ management_type?: 'PEO' | 'EOR' | 'COR';
114
+
115
+ /**
116
+ * The physical address of the entity, if it differs from the mailing address.
117
+ */
118
+ physical_address?: Shared.Address;
119
+
120
+ /**
121
+ * The registration date of the entity.
122
+ */
123
+ registration_date?: string;
124
+
125
+ /**
126
+ * The tax identifier for this entity.
127
+ */
128
+ tax_identifier?: string;
129
+ }
130
+
131
+ /**
132
+ * Meta information for the response.
133
+ */
134
+ export interface CompanyLegalEntityRetrieveResponse extends BusinessPartnersAPI.Meta {
135
+ /**
136
+ * Identifier field
137
+ */
138
+ id: string;
139
+
140
+ /**
141
+ * Record creation date
142
+ */
143
+ created_at: string;
144
+
145
+ /**
146
+ * Record update date
147
+ */
148
+ updated_at: string;
149
+
150
+ /**
151
+ * The company associated with this entity relationship.
152
+ */
153
+ company_id?: string;
154
+
155
+ /**
156
+ * The ISO country code for the entity.
157
+ */
158
+ country_code?: string;
159
+
160
+ /**
161
+ * The entity's level in a hierarchy. _ `PARENT`: The legal entity is considered
162
+ * the ultimate holding entity. _ `SUBSIDIARY`: The legal entity is considered a
163
+ * subsidiary, fully or partially held by another. \* `BRANCH`: The legal entity is
164
+ * considered a branch, associated with a parent legal entity.
165
+ */
166
+ entity_level?: 'PARENT' | 'SUBSIDIARY' | 'BRANCH';
167
+
168
+ /**
169
+ * True if this entity relationship has been archived.
170
+ */
171
+ is_archived?: boolean;
172
+
173
+ /**
174
+ * True if this entity is managed as a Contractor of Record.
175
+ */
176
+ is_cor?: boolean;
177
+
178
+ /**
179
+ * True if this entity is managed as an Employer of Record.
180
+ */
181
+ is_eor?: boolean;
182
+
183
+ /**
184
+ * True if this entity is managed as a Professional Employment Organization.
185
+ */
186
+ is_peo?: boolean;
187
+
188
+ /**
189
+ * The legal name of the entity.
190
+ */
191
+ legal_name?: string;
192
+
193
+ /**
194
+ * The mailing address of the entity.
195
+ */
196
+ mailing_address?: Shared.Address;
197
+
198
+ /**
199
+ * The entity management type. _ `EOR`: The entity is managed as an Employer of
200
+ * Record. _ `COR`: The entity is managed as a Contractor of Record. _ `PEO`: The
201
+ * entity is managed as a Professional Employment Organization. _ `null`: The
202
+ * entity is a direct hire with no managed employment type.
203
+ */
204
+ management_type?: 'PEO' | 'EOR' | 'COR';
205
+
206
+ /**
207
+ * The physical address of the entity, if it differs from the mailing address.
208
+ */
209
+ physical_address?: Shared.Address;
210
+
211
+ /**
212
+ * The registration date of the entity.
213
+ */
214
+ registration_date?: string;
215
+
216
+ /**
217
+ * The tax identifier for this entity.
218
+ */
219
+ tax_identifier?: string;
220
+ }
221
+
222
+ export interface CompanyLegalEntityListParams {
223
+ cursor?: string;
224
+
225
+ filter?: string;
226
+
227
+ order_by?: string;
228
+ }
229
+
230
+ export declare namespace CompanyLegalEntities {
231
+ export {
232
+ type CompanyLegalEntityListResponse as CompanyLegalEntityListResponse,
233
+ type CompanyLegalEntityRetrieveResponse as CompanyLegalEntityRetrieveResponse,
234
+ type CompanyLegalEntityListResponsesPageCursorURL as CompanyLegalEntityListResponsesPageCursorURL,
235
+ type CompanyLegalEntityListParams as CompanyLegalEntityListParams,
236
+ };
237
+ }
@@ -0,0 +1,115 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as BusinessPartnersAPI from './business-partners';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { PageCursorURL, PagePromise } from '../core/pagination';
7
+ import { RequestOptions } from '../internal/request-options';
8
+ import { path } from '../internal/utils/path';
9
+
10
+ /**
11
+ * Workers who work or have worked at the company
12
+ */
13
+ export class CompanyLegalEntityWorkers extends APIResource {
14
+ /**
15
+ * A list of company-legal-entity-workers.
16
+ *
17
+ * - Requires: `API Tier 2`
18
+ * - Filterable fields: `status`, `company_entity_id`
19
+ * - Sortable fields: `id`, `created_at`, `updated_at`
20
+ */
21
+ list(
22
+ query: CompanyLegalEntityWorkerListParams | null | undefined = {},
23
+ options?: RequestOptions,
24
+ ): PagePromise<CompanyLegalEntityWorkerListResponsesPageCursorURL, CompanyLegalEntityWorkerListResponse> {
25
+ return this._client.getAPIList(
26
+ '/company-legal-entity-workers/',
27
+ PageCursorURL<CompanyLegalEntityWorkerListResponse>,
28
+ { query, ...options },
29
+ );
30
+ }
31
+
32
+ /**
33
+ * Retrieve a specific company-legal-entity-worker
34
+ */
35
+ retrieve(id: string, options?: RequestOptions): APIPromise<CompanyLegalEntityWorkerRetrieveResponse> {
36
+ return this._client.get(path`/company-legal-entity-workers/${id}/`, options);
37
+ }
38
+ }
39
+
40
+ export type CompanyLegalEntityWorkerListResponsesPageCursorURL =
41
+ PageCursorURL<CompanyLegalEntityWorkerListResponse>;
42
+
43
+ export interface CompanyLegalEntityWorkerListResponse {
44
+ /**
45
+ * Identifier field
46
+ */
47
+ id: string;
48
+
49
+ /**
50
+ * Record creation date
51
+ */
52
+ created_at: string;
53
+
54
+ /**
55
+ * Record update date
56
+ */
57
+ updated_at: string;
58
+
59
+ /**
60
+ * The worker's associated company legal entity (CER ID).
61
+ */
62
+ company_entity_id?: string;
63
+
64
+ /**
65
+ * The worker's status within the organization.
66
+ */
67
+ status?: 'INIT' | 'HIRED' | 'ACCEPTED' | 'ACTIVE' | 'TERMINATED';
68
+ }
69
+
70
+ /**
71
+ * Meta information for the response.
72
+ */
73
+ export interface CompanyLegalEntityWorkerRetrieveResponse extends BusinessPartnersAPI.Meta {
74
+ /**
75
+ * Identifier field
76
+ */
77
+ id: string;
78
+
79
+ /**
80
+ * Record creation date
81
+ */
82
+ created_at: string;
83
+
84
+ /**
85
+ * Record update date
86
+ */
87
+ updated_at: string;
88
+
89
+ /**
90
+ * The worker's associated company legal entity (CER ID).
91
+ */
92
+ company_entity_id?: string;
93
+
94
+ /**
95
+ * The worker's status within the organization.
96
+ */
97
+ status?: 'INIT' | 'HIRED' | 'ACCEPTED' | 'ACTIVE' | 'TERMINATED';
98
+ }
99
+
100
+ export interface CompanyLegalEntityWorkerListParams {
101
+ cursor?: string;
102
+
103
+ filter?: string;
104
+
105
+ order_by?: string;
106
+ }
107
+
108
+ export declare namespace CompanyLegalEntityWorkers {
109
+ export {
110
+ type CompanyLegalEntityWorkerListResponse as CompanyLegalEntityWorkerListResponse,
111
+ type CompanyLegalEntityWorkerRetrieveResponse as CompanyLegalEntityWorkerRetrieveResponse,
112
+ type CompanyLegalEntityWorkerListResponsesPageCursorURL as CompanyLegalEntityWorkerListResponsesPageCursorURL,
113
+ type CompanyLegalEntityWorkerListParams as CompanyLegalEntityWorkerListParams,
114
+ };
115
+ }
@@ -11,7 +11,7 @@ export class EarningTypes extends APIResource {
11
11
  /**
12
12
  * A list of earning-types.
13
13
  *
14
- * - Requires: `Payroll API`
14
+ * - Requires: `Global Payroll`
15
15
  */
16
16
  list(
17
17
  options?: RequestOptions,
@@ -34,12 +34,6 @@ export interface EarningTypeListResponse {
34
34
  */
35
35
  id?: string;
36
36
 
37
- /**
38
- * Company entity relationship identifier (CER ID) linking the earning type to the
39
- * HRIS legal entity.
40
- */
41
- company_entity_id?: string;
42
-
43
37
  /**
44
38
  * ISO country code where the earning type applies.
45
39
  */