@nextplus/js-sdk 0.0.9 → 0.0.11

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/index.cjs CHANGED
@@ -32,9 +32,117 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32
32
  // src/index.ts
33
33
  var index_exports = {};
34
34
  __export(index_exports, {
35
+ AclService: () => AclService,
36
+ AddonService: () => AddonService,
37
+ AiPromptService: () => AiPromptService,
38
+ AiService: () => AiService,
39
+ ApiMethodLogService: () => ApiMethodLogService,
40
+ ApiMethodService: () => ApiMethodService,
41
+ BomService: () => BomService,
42
+ BreakService: () => BreakService,
43
+ BreakTypeService: () => BreakTypeService,
44
+ CatalogService: () => CatalogService,
45
+ CategoryService: () => CategoryService,
46
+ CertificateMappingService: () => CertificateMappingService,
47
+ CertificateService: () => CertificateService,
48
+ ChapterService: () => ChapterService,
49
+ ChatThreadService: () => ChatThreadService,
50
+ CommandPaletteHistoryService: () => CommandPaletteHistoryService,
51
+ CommentService: () => CommentService,
52
+ ConfigurationService: () => ConfigurationService,
53
+ ConnectionService: () => ConnectionService,
54
+ ConnectorFunctionService: () => ConnectorFunctionService,
55
+ ConnectorService: () => ConnectorService,
56
+ ContainerService: () => ContainerService,
57
+ ContentPackageService: () => ContentPackageService,
58
+ ContentPackageSessionService: () => ContentPackageSessionService,
59
+ ContentPackageViewService: () => ContentPackageViewService,
60
+ CustomFieldService: () => CustomFieldService,
61
+ DeviceFamilyService: () => DeviceFamilyService,
62
+ DeviceService: () => DeviceService,
63
+ DigestEmailService: () => DigestEmailService,
64
+ DocumentService: () => DocumentService,
65
+ EventService: () => EventService,
66
+ FieldService: () => FieldService,
67
+ FileParserJobService: () => FileParserJobService,
68
+ FileParserService: () => FileParserService,
69
+ FileParserStrategyJobService: () => FileParserStrategyJobService,
70
+ FolderService: () => FolderService,
71
+ FormDataCommentService: () => FormDataCommentService,
72
+ FormDataService: () => FormDataService,
73
+ FormService: () => FormService,
74
+ ForumService: () => ForumService,
75
+ GatewayService: () => GatewayService,
76
+ GroupService: () => GroupService,
77
+ IntegrationBuilderService: () => IntegrationBuilderService,
78
+ InventoryTransactionService: () => InventoryTransactionService,
79
+ LastSeenResourceService: () => LastSeenResourceService,
80
+ ListItemService: () => ListItemService,
81
+ ListService: () => ListService,
82
+ LocationService: () => LocationService,
83
+ MenusService: () => MenusService,
35
84
  NextPlusSDK: () => NextPlusSDK,
85
+ NodeService: () => NodeService,
86
+ NpsService: () => NpsService,
87
+ OpcUaServerService: () => OpcUaServerService,
88
+ OperationService: () => OperationService,
89
+ PagesService: () => PagesService,
90
+ PartAssemblyDocumentService: () => PartAssemblyDocumentService,
91
+ PartAssemblyService: () => PartAssemblyService,
92
+ PartService: () => PartService,
93
+ PostService: () => PostService,
94
+ PrintPresetService: () => PrintPresetService,
95
+ PriorityLabelService: () => PriorityLabelService,
96
+ PriorityService: () => PriorityService,
97
+ ProductionEntityEventService: () => ProductionEntityEventService,
98
+ ProductionEntityService: () => ProductionEntityService,
99
+ ProductionEntityTransactionService: () => ProductionEntityTransactionService,
100
+ ProductionEntityTypeService: () => ProductionEntityTypeService,
101
+ ProjectService: () => ProjectService,
102
+ ResourceService: () => ResourceService,
103
+ RevisionService: () => RevisionService,
104
+ RoleService: () => RoleService,
105
+ RuleService: () => RuleService,
106
+ ScromSessionService: () => ScromSessionService,
107
+ SettingService: () => SettingService,
108
+ ShiftService: () => ShiftService,
109
+ ShiftTypeService: () => ShiftTypeService,
110
+ SqlServerService: () => SqlServerService,
111
+ StationService: () => StationService,
112
+ StockService: () => StockService,
113
+ SyncClientsService: () => SyncClientsService,
114
+ SyncHistoryService: () => SyncHistoryService,
115
+ SyncService: () => SyncService,
116
+ TableService: () => TableService,
117
+ TableSetupService: () => TableSetupService,
118
+ TimeLogReportService: () => TimeLogReportService,
119
+ TimelineService: () => TimelineService,
120
+ ToolExecutionResultService: () => ToolExecutionResultService,
121
+ ToolService: () => ToolService,
122
+ TranslationService: () => TranslationService,
123
+ UnitService: () => UnitService,
124
+ UpdateInfoService: () => UpdateInfoService,
125
+ UserModelService: () => UserModelService,
126
+ VariantService: () => VariantService,
127
+ VoteMappingService: () => VoteMappingService,
128
+ WarehouseService: () => WarehouseService,
129
+ WebhookService: () => WebhookService,
130
+ WireService: () => WireService,
131
+ WiringlistService: () => WiringlistService,
132
+ WorkflowDetailsService: () => WorkflowDetailsService,
133
+ WorkflowService: () => WorkflowService,
134
+ WorkflowSessionItemRecordService: () => WorkflowSessionItemRecordService,
135
+ WorkflowSessionItemService: () => WorkflowSessionItemService,
136
+ WorkflowTypeService: () => WorkflowTypeService,
137
+ WorkorderService: () => WorkorderService,
138
+ WorkorderStatusService: () => WorkorderStatusService,
139
+ WorkorderStatusTransitionService: () => WorkorderStatusTransitionService,
140
+ WorkorderTemplateService: () => WorkorderTemplateService,
141
+ clearDefaultClient: () => clearDefaultClient,
36
142
  configure: () => configure,
37
- createSDK: () => createSDK
143
+ createSDK: () => createSDK,
144
+ getDefaultClient: () => getDefaultClient,
145
+ setDefaultClient: () => setDefaultClient
38
146
  });
39
147
  module.exports = __toCommonJS(index_exports);
40
148
  var import_debug = __toESM(require("debug"), 1);
@@ -638,6 +746,8 @@ __export(sdk_exports, {
638
746
  CertificateMappingService: () => CertificateMappingService,
639
747
  CertificateService: () => CertificateService,
640
748
  ChapterService: () => ChapterService,
749
+ ChatThreadService: () => ChatThreadService,
750
+ CommandPaletteHistoryService: () => CommandPaletteHistoryService,
641
751
  CommentService: () => CommentService,
642
752
  ConfigurationService: () => ConfigurationService,
643
753
  ConnectionService: () => ConnectionService,
@@ -696,6 +806,7 @@ __export(sdk_exports, {
696
806
  SettingService: () => SettingService,
697
807
  ShiftService: () => ShiftService,
698
808
  ShiftTypeService: () => ShiftTypeService,
809
+ SqlServerService: () => SqlServerService,
699
810
  StationService: () => StationService,
700
811
  StockService: () => StockService,
701
812
  SyncClientsService: () => SyncClientsService,
@@ -724,6 +835,7 @@ __export(sdk_exports, {
724
835
  WorkflowTypeService: () => WorkflowTypeService,
725
836
  WorkorderService: () => WorkorderService,
726
837
  WorkorderStatusService: () => WorkorderStatusService,
838
+ WorkorderStatusTransitionService: () => WorkorderStatusTransitionService,
727
839
  WorkorderTemplateService: () => WorkorderTemplateService
728
840
  });
729
841
 
@@ -1184,6 +1296,9 @@ var resourceSchemaResponseTransformer = (data) => {
1184
1296
  if (data.serverModified) {
1185
1297
  data.serverModified = new Date(data.serverModified);
1186
1298
  }
1299
+ if (data.deletedAt) {
1300
+ data.deletedAt = new Date(data.deletedAt);
1301
+ }
1187
1302
  return data;
1188
1303
  };
1189
1304
  var partAssemblyPrototypeGetImageObjectResponseTransformer = async (data) => {
@@ -4146,6 +4261,36 @@ var workorderStatusFindOneResponseTransformer = async (data) => {
4146
4261
  data = workorderStatusSchemaResponseTransformer(data);
4147
4262
  return data;
4148
4263
  };
4264
+ var workorderStatusTransitionSchemaResponseTransformer = (data) => {
4265
+ if (data.created) {
4266
+ data.created = new Date(data.created);
4267
+ }
4268
+ if (data.modified) {
4269
+ data.modified = new Date(data.modified);
4270
+ }
4271
+ if (data.serverModified) {
4272
+ data.serverModified = new Date(data.serverModified);
4273
+ }
4274
+ return data;
4275
+ };
4276
+ var workorderStatusTransitionFindResponseTransformer = async (data) => {
4277
+ data = data.map((item) => {
4278
+ return workorderStatusTransitionSchemaResponseTransformer(item);
4279
+ });
4280
+ return data;
4281
+ };
4282
+ var workorderStatusTransitionCreateResponseTransformer = async (data) => {
4283
+ data = workorderStatusTransitionSchemaResponseTransformer(data);
4284
+ return data;
4285
+ };
4286
+ var workorderStatusTransitionFindOneResponseTransformer = async (data) => {
4287
+ data = workorderStatusTransitionSchemaResponseTransformer(data);
4288
+ return data;
4289
+ };
4290
+ var workorderStatusTransitionPrototypePatchAttributesResponseTransformer = async (data) => {
4291
+ data = workorderStatusTransitionSchemaResponseTransformer(data);
4292
+ return data;
4293
+ };
4149
4294
  var timeLogReportSchemaResponseTransformer = (data) => {
4150
4295
  if (data.start) {
4151
4296
  data.start = new Date(data.start);
@@ -5047,6 +5192,163 @@ var addonFindOneResponseTransformer = async (data) => {
5047
5192
  data = addonSchemaResponseTransformer(data);
5048
5193
  return data;
5049
5194
  };
5195
+ var sqlServerPrototypeGetUserResponseTransformer = async (data) => {
5196
+ data = userModelSchemaResponseTransformer(data);
5197
+ return data;
5198
+ };
5199
+ var sqlServerSchemaResponseTransformer = (data) => {
5200
+ if (data.created) {
5201
+ data.created = new Date(data.created);
5202
+ }
5203
+ if (data.modified) {
5204
+ data.modified = new Date(data.modified);
5205
+ }
5206
+ if (data.serverModified) {
5207
+ data.serverModified = new Date(data.serverModified);
5208
+ }
5209
+ if (data.deletedAt) {
5210
+ data.deletedAt = new Date(data.deletedAt);
5211
+ }
5212
+ return data;
5213
+ };
5214
+ var sqlServerFindResponseTransformer = async (data) => {
5215
+ data = data.map((item) => {
5216
+ return sqlServerSchemaResponseTransformer(item);
5217
+ });
5218
+ return data;
5219
+ };
5220
+ var sqlServerPatchOrCreateResponseTransformer = async (data) => {
5221
+ data = sqlServerSchemaResponseTransformer(data);
5222
+ return data;
5223
+ };
5224
+ var sqlServerCreateResponseTransformer = async (data) => {
5225
+ data = sqlServerSchemaResponseTransformer(data);
5226
+ return data;
5227
+ };
5228
+ var sqlServerReplaceOrCreatePutSqlServersResponseTransformer = async (data) => {
5229
+ data = sqlServerSchemaResponseTransformer(data);
5230
+ return data;
5231
+ };
5232
+ var sqlServerReplaceOrCreatePostSqlServersReplaceOrCreateResponseTransformer = async (data) => {
5233
+ data = sqlServerSchemaResponseTransformer(data);
5234
+ return data;
5235
+ };
5236
+ var sqlServerUpsertWithWhereResponseTransformer = async (data) => {
5237
+ data = sqlServerSchemaResponseTransformer(data);
5238
+ return data;
5239
+ };
5240
+ var sqlServerFindByIdResponseTransformer = async (data) => {
5241
+ data = sqlServerSchemaResponseTransformer(data);
5242
+ return data;
5243
+ };
5244
+ var sqlServerPrototypePatchAttributesResponseTransformer = async (data) => {
5245
+ data = sqlServerSchemaResponseTransformer(data);
5246
+ return data;
5247
+ };
5248
+ var sqlServerReplaceByIdPutSqlServersIdResponseTransformer = async (data) => {
5249
+ data = sqlServerSchemaResponseTransformer(data);
5250
+ return data;
5251
+ };
5252
+ var sqlServerReplaceByIdPostSqlServersIdReplaceResponseTransformer = async (data) => {
5253
+ data = sqlServerSchemaResponseTransformer(data);
5254
+ return data;
5255
+ };
5256
+ var sqlServerFindOneResponseTransformer = async (data) => {
5257
+ data = sqlServerSchemaResponseTransformer(data);
5258
+ return data;
5259
+ };
5260
+ var chatThreadPrototypeGetUserResponseTransformer = async (data) => {
5261
+ data = userModelSchemaResponseTransformer(data);
5262
+ return data;
5263
+ };
5264
+ var chatThreadSchemaResponseTransformer = (data) => {
5265
+ if (data.created) {
5266
+ data.created = new Date(data.created);
5267
+ }
5268
+ if (data.modified) {
5269
+ data.modified = new Date(data.modified);
5270
+ }
5271
+ if (data.serverModified) {
5272
+ data.serverModified = new Date(data.serverModified);
5273
+ }
5274
+ return data;
5275
+ };
5276
+ var chatThreadFindResponseTransformer = async (data) => {
5277
+ data = data.map((item) => {
5278
+ return chatThreadSchemaResponseTransformer(item);
5279
+ });
5280
+ return data;
5281
+ };
5282
+ var chatThreadPatchOrCreateResponseTransformer = async (data) => {
5283
+ data = chatThreadSchemaResponseTransformer(data);
5284
+ return data;
5285
+ };
5286
+ var chatThreadCreateResponseTransformer = async (data) => {
5287
+ data = chatThreadSchemaResponseTransformer(data);
5288
+ return data;
5289
+ };
5290
+ var chatThreadReplaceOrCreatePutChatThreadsResponseTransformer = async (data) => {
5291
+ data = chatThreadSchemaResponseTransformer(data);
5292
+ return data;
5293
+ };
5294
+ var chatThreadReplaceOrCreatePostChatThreadsReplaceOrCreateResponseTransformer = async (data) => {
5295
+ data = chatThreadSchemaResponseTransformer(data);
5296
+ return data;
5297
+ };
5298
+ var chatThreadUpsertWithWhereResponseTransformer = async (data) => {
5299
+ data = chatThreadSchemaResponseTransformer(data);
5300
+ return data;
5301
+ };
5302
+ var chatThreadFindByIdResponseTransformer = async (data) => {
5303
+ data = chatThreadSchemaResponseTransformer(data);
5304
+ return data;
5305
+ };
5306
+ var chatThreadPrototypePatchAttributesResponseTransformer = async (data) => {
5307
+ data = chatThreadSchemaResponseTransformer(data);
5308
+ return data;
5309
+ };
5310
+ var chatThreadReplaceByIdPutChatThreadsIdResponseTransformer = async (data) => {
5311
+ data = chatThreadSchemaResponseTransformer(data);
5312
+ return data;
5313
+ };
5314
+ var chatThreadReplaceByIdPostChatThreadsIdReplaceResponseTransformer = async (data) => {
5315
+ data = chatThreadSchemaResponseTransformer(data);
5316
+ return data;
5317
+ };
5318
+ var chatThreadFindOneResponseTransformer = async (data) => {
5319
+ data = chatThreadSchemaResponseTransformer(data);
5320
+ return data;
5321
+ };
5322
+ var commandPaletteHistorySchemaResponseTransformer = (data) => {
5323
+ data.lastVisited = new Date(data.lastVisited);
5324
+ if (data.created) {
5325
+ data.created = new Date(data.created);
5326
+ }
5327
+ if (data.modified) {
5328
+ data.modified = new Date(data.modified);
5329
+ }
5330
+ if (data.serverModified) {
5331
+ data.serverModified = new Date(data.serverModified);
5332
+ }
5333
+ if (data.deletedAt) {
5334
+ data.deletedAt = new Date(data.deletedAt);
5335
+ }
5336
+ return data;
5337
+ };
5338
+ var commandPaletteHistoryFindResponseTransformer = async (data) => {
5339
+ data = data.map((item) => {
5340
+ return commandPaletteHistorySchemaResponseTransformer(item);
5341
+ });
5342
+ return data;
5343
+ };
5344
+ var commandPaletteHistoryCreateResponseTransformer = async (data) => {
5345
+ data = commandPaletteHistorySchemaResponseTransformer(data);
5346
+ return data;
5347
+ };
5348
+ var commandPaletteHistoryPrototypePatchAttributesResponseTransformer = async (data) => {
5349
+ data = commandPaletteHistorySchemaResponseTransformer(data);
5350
+ return data;
5351
+ };
5050
5352
 
5051
5353
  // src/sdk/sdk.gen.ts
5052
5354
  var ContainerService = class {
@@ -9002,6 +9304,19 @@ var ResourceService = class {
9002
9304
  }
9003
9305
  });
9004
9306
  }
9307
+ /**
9308
+ * Delete file if not used on another session
9309
+ */
9310
+ static deleteFileIfNotUsed(options) {
9311
+ return (options.client ?? client).post({
9312
+ url: "/Resources/deleteFileIfNotUsed",
9313
+ ...options,
9314
+ headers: {
9315
+ "Content-Type": "application/json",
9316
+ ...options.headers
9317
+ }
9318
+ });
9319
+ }
9005
9320
  static processingFile(options) {
9006
9321
  return (options?.client ?? client).get({
9007
9322
  url: "/Resources/processingFile",
@@ -9030,6 +9345,24 @@ var ResourceService = class {
9030
9345
  }
9031
9346
  });
9032
9347
  }
9348
+ /**
9349
+ * Get file as base64-encoded buffer in JSON response
9350
+ */
9351
+ static getFileAsBuffer(options) {
9352
+ return (options.client ?? client).get({
9353
+ url: "/Resources/buffer/{id}",
9354
+ ...options
9355
+ });
9356
+ }
9357
+ /**
9358
+ * Count with deleted instances of the model matched by where from the data source.
9359
+ */
9360
+ static countWithDeleted(options) {
9361
+ return (options?.client ?? client).get({
9362
+ url: "/Resources/countWithDeleted",
9363
+ ...options
9364
+ });
9365
+ }
9033
9366
  };
9034
9367
  var WorkflowService = class {
9035
9368
  /**
@@ -10028,13 +10361,9 @@ var WorkflowService = class {
10028
10361
  }
10029
10362
  });
10030
10363
  }
10031
- /**
10032
- * Fork a workflow
10033
- */
10034
- static fork(options) {
10364
+ static prototypeImportFromZip(options) {
10035
10365
  return (options.client ?? client).post({
10036
- responseTransformer: workflowForkResponseTransformer,
10037
- url: "/Workflows/fork",
10366
+ url: "/Workflows/{id}/importFromZip",
10038
10367
  ...options,
10039
10368
  headers: {
10040
10369
  "Content-Type": "application/json",
@@ -10042,7 +10371,21 @@ var WorkflowService = class {
10042
10371
  }
10043
10372
  });
10044
10373
  }
10045
- static exportModel(options) {
10374
+ /**
10375
+ * Fork a workflow
10376
+ */
10377
+ static fork(options) {
10378
+ return (options.client ?? client).post({
10379
+ responseTransformer: workflowForkResponseTransformer,
10380
+ url: "/Workflows/fork",
10381
+ ...options,
10382
+ headers: {
10383
+ "Content-Type": "application/json",
10384
+ ...options.headers
10385
+ }
10386
+ });
10387
+ }
10388
+ static exportModel(options) {
10046
10389
  return (options?.client ?? client).post({
10047
10390
  url: "/Workflows/exportModel",
10048
10391
  ...options,
@@ -11666,6 +12009,19 @@ var ToolService = class {
11666
12009
  ...options
11667
12010
  });
11668
12011
  }
12012
+ /**
12013
+ * Import tools and serials from CSV-like data with validation
12014
+ */
12015
+ static importTools(options) {
12016
+ return (options.client ?? client).post({
12017
+ url: "/Tools/import",
12018
+ ...options,
12019
+ headers: {
12020
+ "Content-Type": "application/json",
12021
+ ...options.headers
12022
+ }
12023
+ });
12024
+ }
11669
12025
  static exportTranslations(options) {
11670
12026
  return (options.client ?? client).get({
11671
12027
  url: "/Tools/exportTranslations",
@@ -12052,6 +12408,15 @@ var WorkorderService = class {
12052
12408
  ...options
12053
12409
  });
12054
12410
  }
12411
+ /**
12412
+ * Get status change history for a workorder
12413
+ */
12414
+ static getStatusHistory(options) {
12415
+ return (options.client ?? client).get({
12416
+ url: "/Workorders/getStatusHistory",
12417
+ ...options
12418
+ });
12419
+ }
12055
12420
  /**
12056
12421
  * Work on a specific stock
12057
12422
  */
@@ -15264,6 +15629,16 @@ var FormDataService = class {
15264
15629
  }
15265
15630
  });
15266
15631
  }
15632
+ static updateFormData(options) {
15633
+ return (options.client ?? client).patch({
15634
+ url: "/FormData/updateFormData/{formDataId}",
15635
+ ...options,
15636
+ headers: {
15637
+ "Content-Type": "application/json",
15638
+ ...options.headers
15639
+ }
15640
+ });
15641
+ }
15267
15642
  };
15268
15643
  var FolderService = class {
15269
15644
  /**
@@ -17586,24 +17961,6 @@ var WorkorderStatusService = class {
17586
17961
  }
17587
17962
  });
17588
17963
  }
17589
- /**
17590
- * get Current Status Fields
17591
- */
17592
- static getFieldsByFieldIds(options) {
17593
- return (options.client ?? client).get({
17594
- url: "/WorkorderStatuses/getFieldsByFieldIds",
17595
- ...options
17596
- });
17597
- }
17598
- /**
17599
- * check user status change permission
17600
- */
17601
- static checkPermission(options) {
17602
- return (options.client ?? client).get({
17603
- url: "/WorkorderStatuses/checkPermission",
17604
- ...options
17605
- });
17606
- }
17607
17964
  /**
17608
17965
  * Change workorder status
17609
17966
  */
@@ -17631,11 +17988,70 @@ var WorkorderStatusService = class {
17631
17988
  });
17632
17989
  }
17633
17990
  /**
17634
- * bulk workorder status change
17991
+ * delete Workorder Status
17635
17992
  */
17636
- static bulkWorkorderStatusChange(options) {
17993
+ static deleteWorkorderStatus(options) {
17637
17994
  return (options.client ?? client).post({
17638
- url: "/WorkorderStatuses/bulkWorkorderStatusChange",
17995
+ url: "/WorkorderStatuses/deleteWorkorderStatus",
17996
+ ...options,
17997
+ headers: {
17998
+ "Content-Type": "application/json",
17999
+ ...options.headers
18000
+ }
18001
+ });
18002
+ }
18003
+ };
18004
+ var WorkorderStatusTransitionService = class {
18005
+ /**
18006
+ * Find all instances of the model matched by filter from the data source.
18007
+ */
18008
+ static find(options) {
18009
+ return (options?.client ?? client).get({
18010
+ responseTransformer: workorderStatusTransitionFindResponseTransformer,
18011
+ url: "/WorkorderStatusTransitions",
18012
+ ...options
18013
+ });
18014
+ }
18015
+ /**
18016
+ * Create a new instance of the model and persist it into the data source.
18017
+ */
18018
+ static create(options) {
18019
+ return (options?.client ?? client).post({
18020
+ responseTransformer: workorderStatusTransitionCreateResponseTransformer,
18021
+ url: "/WorkorderStatusTransitions",
18022
+ ...options,
18023
+ headers: {
18024
+ "Content-Type": "application/json",
18025
+ ...options?.headers
18026
+ }
18027
+ });
18028
+ }
18029
+ /**
18030
+ * Find first instance of the model matched by filter from the data source.
18031
+ */
18032
+ static findOne(options) {
18033
+ return (options?.client ?? client).get({
18034
+ responseTransformer: workorderStatusTransitionFindOneResponseTransformer,
18035
+ url: "/WorkorderStatusTransitions/findOne",
18036
+ ...options
18037
+ });
18038
+ }
18039
+ /**
18040
+ * Delete a model instance by {{id}} from the data source.
18041
+ */
18042
+ static deleteById(options) {
18043
+ return (options.client ?? client).delete({
18044
+ url: "/WorkorderStatusTransitions/{id}",
18045
+ ...options
18046
+ });
18047
+ }
18048
+ /**
18049
+ * Patch attributes for a model instance and persist it into the data source.
18050
+ */
18051
+ static prototypePatchAttributes(options) {
18052
+ return (options.client ?? client).patch({
18053
+ responseTransformer: workorderStatusTransitionPrototypePatchAttributesResponseTransformer,
18054
+ url: "/WorkorderStatusTransitions/{id}",
17639
18055
  ...options,
17640
18056
  headers: {
17641
18057
  "Content-Type": "application/json",
@@ -17643,6 +18059,42 @@ var WorkorderStatusService = class {
17643
18059
  }
17644
18060
  });
17645
18061
  }
18062
+ /**
18063
+ * Count instances of the model matched by where from the data source.
18064
+ */
18065
+ static count(options) {
18066
+ return (options?.client ?? client).get({
18067
+ url: "/WorkorderStatusTransitions/count",
18068
+ ...options
18069
+ });
18070
+ }
18071
+ /**
18072
+ * get Fields by field ids
18073
+ */
18074
+ static getFieldsByFieldIds(options) {
18075
+ return (options.client ?? client).get({
18076
+ url: "/WorkorderStatusTransitions/getFieldsByFieldIds",
18077
+ ...options
18078
+ });
18079
+ }
18080
+ /**
18081
+ * get Transition by id
18082
+ */
18083
+ static getTransitionWithFields(options) {
18084
+ return (options.client ?? client).get({
18085
+ url: "/WorkorderStatusTransitions/getTransitionWithFields",
18086
+ ...options
18087
+ });
18088
+ }
18089
+ /**
18090
+ * get Transition by source and target status
18091
+ */
18092
+ static getTransitionBySourceAndTargetStatus(options) {
18093
+ return (options.client ?? client).get({
18094
+ url: "/WorkorderStatusTransitions/getTransitionBySourceAndTargetStatus",
18095
+ ...options
18096
+ });
18097
+ }
17646
18098
  };
17647
18099
  var TimeLogReportService = class {
17648
18100
  /**
@@ -20738,137 +21190,781 @@ var IntegrationBuilderService = class {
20738
21190
  });
20739
21191
  }
20740
21192
  };
20741
-
20742
- // src/index.ts
20743
- var log = (0, import_debug.default)("nextplus:sdk");
20744
- var accessToken = {
20745
- token: null,
20746
- created: null,
20747
- ttl: 0
20748
- };
20749
- var setAccessToken = (token, created = /* @__PURE__ */ new Date(), ttl = 1209600) => {
20750
- accessToken.token = token;
20751
- accessToken.created = created;
20752
- accessToken.ttl = ttl;
20753
- };
20754
- var getAccessToken = () => {
20755
- return accessToken;
20756
- };
20757
- var isTokenValid = () => {
20758
- if (!accessToken.token || !accessToken.created) {
20759
- return false;
21193
+ var SqlServerService = class {
21194
+ /**
21195
+ * Fetches belongsTo relation user.
21196
+ */
21197
+ static prototypeGetUser(options) {
21198
+ return (options.client ?? client).get({
21199
+ responseTransformer: sqlServerPrototypeGetUserResponseTransformer,
21200
+ url: "/SqlServers/{id}/user",
21201
+ ...options
21202
+ });
20760
21203
  }
20761
- const now = /* @__PURE__ */ new Date();
20762
- const tokenAge = now.getTime() - accessToken.created.getTime();
20763
- const tokenTtlMs = accessToken.ttl * 1e3;
20764
- return tokenAge < tokenTtlMs;
20765
- };
20766
- var NextPlusSDK = class {
20767
- constructor(options) {
20768
- __publicField(this, "client");
20769
- __publicField(this, "credentials");
20770
- __publicField(this, "returnType", "data");
20771
- if (!options.email && !options.username) {
20772
- throw new Error("Either email or username must be provided");
20773
- }
20774
- if (options.email && options.username) {
20775
- throw new Error("Provide either email or username, not both");
20776
- }
20777
- this.credentials = {
20778
- email: options.email,
20779
- username: options.username,
20780
- password: options.password
20781
- };
20782
- this.returnType = options.returnType || "data";
20783
- if (options.baseURL.endsWith("/")) {
20784
- options.baseURL = options.baseURL.slice(0, -1);
20785
- }
20786
- if (!options.baseURL.endsWith("/api")) {
20787
- options.baseURL = options.baseURL + "/api";
20788
- }
20789
- this.client = createClient({
20790
- baseUrl: options.baseURL
21204
+ /**
21205
+ * Find all instances of the model matched by filter from the data source.
21206
+ */
21207
+ static find(options) {
21208
+ return (options?.client ?? client).get({
21209
+ responseTransformer: sqlServerFindResponseTransformer,
21210
+ url: "/SqlServers",
21211
+ ...options
20791
21212
  });
20792
- this.client.interceptors.request.use(this.authRequestInterceptor.bind(this));
20793
- this.createServiceProxies();
20794
21213
  }
20795
- // Wrap plain developer inputs into the right container (body/query)
20796
- // and stringify complex query params when required by LoopBack (filter/where)
20797
- normalizeOptions(methodName, rawOptions) {
20798
- const options = rawOptions && typeof rawOptions === "object" ? { ...rawOptions } : {};
20799
- const method = methodName.toString().toLowerCase();
20800
- const isFind = method.includes("find") && !method.includes("count");
20801
- const isCount = method.includes("count");
20802
- const shouldUseBody = /(create|update|replace|patch|login|upsert)/i.test(methodName.toString());
20803
- const topLevelKeys = ["filter", "where", "fields", "order", "limit", "offset", "include"];
20804
- const hasTopLevelFilterBits = topLevelKeys.some((k) => Object.prototype.hasOwnProperty.call(options, k));
20805
- if (isFind) {
20806
- options.query = options.query || {};
20807
- if (options.filter && typeof options.filter === "object") {
20808
- options.query.filter = JSON.stringify(options.filter);
20809
- delete options.filter;
20810
- } else if (hasTopLevelFilterBits) {
20811
- const filterObject = {};
20812
- if (options.where !== void 0) filterObject.where = options.where;
20813
- if (options.fields !== void 0) filterObject.fields = options.fields;
20814
- if (options.order !== void 0) filterObject.order = options.order;
20815
- if (options.limit !== void 0) filterObject.limit = options.limit;
20816
- if (options.offset !== void 0) filterObject.offset = options.offset;
20817
- if (options.include !== void 0) filterObject.include = options.include;
20818
- if (Object.keys(filterObject).length > 0) {
20819
- options.query.filter = typeof filterObject === "string" ? filterObject : JSON.stringify(filterObject);
20820
- }
20821
- topLevelKeys.forEach((k) => delete options[k]);
20822
- }
20823
- } else if (isCount) {
20824
- options.query = options.query || {};
20825
- if (options.where !== void 0) {
20826
- const whereVal = options.where;
20827
- options.query.where = typeof whereVal === "string" ? whereVal : JSON.stringify(whereVal);
20828
- delete options.where;
20829
- }
20830
- } else if (shouldUseBody) {
20831
- if (options.body === void 0) {
20832
- const bodyCandidate = { ...options };
20833
- delete bodyCandidate.client;
20834
- delete bodyCandidate.query;
20835
- delete bodyCandidate.path;
20836
- if (Object.keys(bodyCandidate).length > 0) {
20837
- options.body = bodyCandidate;
20838
- Object.keys(options).forEach((k) => {
20839
- if (!["body", "client", "query", "path"].includes(k)) delete options[k];
20840
- });
20841
- }
21214
+ /**
21215
+ * Patch an existing model instance or insert a new one into the data source.
21216
+ */
21217
+ static patchOrCreate(options) {
21218
+ return (options?.client ?? client).patch({
21219
+ responseTransformer: sqlServerPatchOrCreateResponseTransformer,
21220
+ url: "/SqlServers",
21221
+ ...options,
21222
+ headers: {
21223
+ "Content-Type": "application/json",
21224
+ ...options?.headers
20842
21225
  }
20843
- }
20844
- if (options.query && typeof options.query === "object") {
20845
- Object.keys(options.query).forEach((key) => {
20846
- const val = options.query[key];
20847
- if (val && (Array.isArray(val) || typeof val === "object")) {
20848
- options.query[key] = JSON.stringify(val);
20849
- }
20850
- });
20851
- }
20852
- return options;
21226
+ });
20853
21227
  }
20854
- async authRequestInterceptor(request, _options) {
20855
- if (request.url.includes("/UserModels/login")) {
20856
- return request;
20857
- }
20858
- await this.ensureValidToken();
20859
- const token = getAccessToken();
20860
- if (token.token) {
20861
- request.headers.set("Authorization", token.token);
20862
- }
20863
- return request;
21228
+ /**
21229
+ * Create a new instance of the model and persist it into the data source.
21230
+ */
21231
+ static create(options) {
21232
+ return (options?.client ?? client).post({
21233
+ responseTransformer: sqlServerCreateResponseTransformer,
21234
+ url: "/SqlServers",
21235
+ ...options,
21236
+ headers: {
21237
+ "Content-Type": "application/json",
21238
+ ...options?.headers
21239
+ }
21240
+ });
21241
+ }
21242
+ /**
21243
+ * Replace an existing model instance or insert a new one into the data source.
21244
+ */
21245
+ static replaceOrCreatePutSqlServers(options) {
21246
+ return (options?.client ?? client).put({
21247
+ responseTransformer: sqlServerReplaceOrCreatePutSqlServersResponseTransformer,
21248
+ url: "/SqlServers",
21249
+ ...options,
21250
+ headers: {
21251
+ "Content-Type": "application/json",
21252
+ ...options?.headers
21253
+ }
21254
+ });
21255
+ }
21256
+ /**
21257
+ * Replace an existing model instance or insert a new one into the data source.
21258
+ */
21259
+ static replaceOrCreatePostSqlServersReplaceOrCreate(options) {
21260
+ return (options?.client ?? client).post({
21261
+ responseTransformer: sqlServerReplaceOrCreatePostSqlServersReplaceOrCreateResponseTransformer,
21262
+ url: "/SqlServers/replaceOrCreate",
21263
+ ...options,
21264
+ headers: {
21265
+ "Content-Type": "application/json",
21266
+ ...options?.headers
21267
+ }
21268
+ });
21269
+ }
21270
+ /**
21271
+ * Update an existing model instance or insert a new one into the data source based on the where criteria.
21272
+ */
21273
+ static upsertWithWhere(options) {
21274
+ return (options?.client ?? client).post({
21275
+ responseTransformer: sqlServerUpsertWithWhereResponseTransformer,
21276
+ url: "/SqlServers/upsertWithWhere",
21277
+ ...options,
21278
+ headers: {
21279
+ "Content-Type": "application/json",
21280
+ ...options?.headers
21281
+ }
21282
+ });
21283
+ }
21284
+ /**
21285
+ * Check whether a model instance exists in the data source.
21286
+ */
21287
+ static existsGetSqlServersIdExists(options) {
21288
+ return (options.client ?? client).get({
21289
+ url: "/SqlServers/{id}/exists",
21290
+ ...options
21291
+ });
21292
+ }
21293
+ /**
21294
+ * Delete a model instance by {{id}} from the data source.
21295
+ */
21296
+ static deleteById(options) {
21297
+ return (options.client ?? client).delete({
21298
+ url: "/SqlServers/{id}",
21299
+ ...options
21300
+ });
21301
+ }
21302
+ /**
21303
+ * Find a model instance by {{id}} from the data source.
21304
+ */
21305
+ static findById(options) {
21306
+ return (options.client ?? client).get({
21307
+ responseTransformer: sqlServerFindByIdResponseTransformer,
21308
+ url: "/SqlServers/{id}",
21309
+ ...options
21310
+ });
21311
+ }
21312
+ /**
21313
+ * Check whether a model instance exists in the data source.
21314
+ */
21315
+ static existsHeadSqlServersId(options) {
21316
+ return (options.client ?? client).head({
21317
+ url: "/SqlServers/{id}",
21318
+ ...options
21319
+ });
21320
+ }
21321
+ /**
21322
+ * Patch attributes for a model instance and persist it into the data source.
21323
+ */
21324
+ static prototypePatchAttributes(options) {
21325
+ return (options.client ?? client).patch({
21326
+ responseTransformer: sqlServerPrototypePatchAttributesResponseTransformer,
21327
+ url: "/SqlServers/{id}",
21328
+ ...options,
21329
+ headers: {
21330
+ "Content-Type": "application/json",
21331
+ ...options.headers
21332
+ }
21333
+ });
21334
+ }
21335
+ /**
21336
+ * Replace attributes for a model instance and persist it into the data source.
21337
+ */
21338
+ static replaceByIdPutSqlServersId(options) {
21339
+ return (options.client ?? client).put({
21340
+ responseTransformer: sqlServerReplaceByIdPutSqlServersIdResponseTransformer,
21341
+ url: "/SqlServers/{id}",
21342
+ ...options,
21343
+ headers: {
21344
+ "Content-Type": "application/json",
21345
+ ...options.headers
21346
+ }
21347
+ });
21348
+ }
21349
+ /**
21350
+ * Replace attributes for a model instance and persist it into the data source.
21351
+ */
21352
+ static replaceByIdPostSqlServersIdReplace(options) {
21353
+ return (options.client ?? client).post({
21354
+ responseTransformer: sqlServerReplaceByIdPostSqlServersIdReplaceResponseTransformer,
21355
+ url: "/SqlServers/{id}/replace",
21356
+ ...options,
21357
+ headers: {
21358
+ "Content-Type": "application/json",
21359
+ ...options.headers
21360
+ }
21361
+ });
21362
+ }
21363
+ /**
21364
+ * Find first instance of the model matched by filter from the data source.
21365
+ */
21366
+ static findOne(options) {
21367
+ return (options?.client ?? client).get({
21368
+ responseTransformer: sqlServerFindOneResponseTransformer,
21369
+ url: "/SqlServers/findOne",
21370
+ ...options
21371
+ });
21372
+ }
21373
+ /**
21374
+ * Update instances of the model matched by {{where}} from the data source.
21375
+ */
21376
+ static updateAll(options) {
21377
+ return (options?.client ?? client).post({
21378
+ url: "/SqlServers/update",
21379
+ ...options,
21380
+ headers: {
21381
+ "Content-Type": "application/json",
21382
+ ...options?.headers
21383
+ }
21384
+ });
21385
+ }
21386
+ /**
21387
+ * Count instances of the model matched by where from the data source.
21388
+ */
21389
+ static count(options) {
21390
+ return (options?.client ?? client).get({
21391
+ url: "/SqlServers/count",
21392
+ ...options
21393
+ });
21394
+ }
21395
+ /**
21396
+ * Add a parameter to SQL server
21397
+ */
21398
+ static addParameter(options) {
21399
+ return (options.client ?? client).post({
21400
+ url: "/SqlServers/addParameter",
21401
+ ...options,
21402
+ headers: {
21403
+ "Content-Type": "application/json",
21404
+ ...options.headers
21405
+ }
21406
+ });
21407
+ }
21408
+ /**
21409
+ * Update a parameter in SQL server
21410
+ */
21411
+ static updateParameter(options) {
21412
+ return (options.client ?? client).put({
21413
+ url: "/SqlServers/updateParameter",
21414
+ ...options,
21415
+ headers: {
21416
+ "Content-Type": "application/json",
21417
+ ...options.headers
21418
+ }
21419
+ });
21420
+ }
21421
+ /**
21422
+ * Delete a parameter from SQL server
21423
+ */
21424
+ static deleteParameter(options) {
21425
+ return (options.client ?? client).delete({
21426
+ url: "/SqlServers/deleteParameter",
21427
+ ...options,
21428
+ headers: {
21429
+ "Content-Type": "application/json",
21430
+ ...options.headers
21431
+ }
21432
+ });
21433
+ }
21434
+ /**
21435
+ * Test connection to SQL server
21436
+ */
21437
+ static testConnection(options) {
21438
+ return (options.client ?? client).post({
21439
+ url: "/SqlServers/testConnection",
21440
+ ...options,
21441
+ headers: {
21442
+ "Content-Type": "application/json",
21443
+ ...options.headers
21444
+ }
21445
+ });
21446
+ }
21447
+ /**
21448
+ * Test parameter query on SQL server
21449
+ */
21450
+ static testQuery(options) {
21451
+ return (options.client ?? client).post({
21452
+ url: "/SqlServers/testQuery",
21453
+ ...options,
21454
+ headers: {
21455
+ "Content-Type": "application/json",
21456
+ ...options.headers
21457
+ }
21458
+ });
21459
+ }
21460
+ /**
21461
+ * Read parameter value from SQL server
21462
+ */
21463
+ static read(options) {
21464
+ return (options.client ?? client).post({
21465
+ url: "/SqlServers/read",
21466
+ ...options,
21467
+ headers: {
21468
+ "Content-Type": "application/json",
21469
+ ...options.headers
21470
+ }
21471
+ });
21472
+ }
21473
+ /**
21474
+ * Count with deleted instances of the model matched by where from the data source.
21475
+ */
21476
+ static countWithDeleted(options) {
21477
+ return (options?.client ?? client).get({
21478
+ url: "/SqlServers/countWithDeleted",
21479
+ ...options
21480
+ });
21481
+ }
21482
+ };
21483
+ var ChatThreadService = class {
21484
+ /**
21485
+ * Fetches belongsTo relation user.
21486
+ */
21487
+ static prototypeGetUser(options) {
21488
+ return (options.client ?? client).get({
21489
+ responseTransformer: chatThreadPrototypeGetUserResponseTransformer,
21490
+ url: "/ChatThreads/{id}/user",
21491
+ ...options
21492
+ });
21493
+ }
21494
+ /**
21495
+ * Find all instances of the model matched by filter from the data source.
21496
+ */
21497
+ static find(options) {
21498
+ return (options?.client ?? client).get({
21499
+ responseTransformer: chatThreadFindResponseTransformer,
21500
+ url: "/ChatThreads",
21501
+ ...options
21502
+ });
21503
+ }
21504
+ /**
21505
+ * Patch an existing model instance or insert a new one into the data source.
21506
+ */
21507
+ static patchOrCreate(options) {
21508
+ return (options?.client ?? client).patch({
21509
+ responseTransformer: chatThreadPatchOrCreateResponseTransformer,
21510
+ url: "/ChatThreads",
21511
+ ...options,
21512
+ headers: {
21513
+ "Content-Type": "application/json",
21514
+ ...options?.headers
21515
+ }
21516
+ });
21517
+ }
21518
+ /**
21519
+ * Create a new instance of the model and persist it into the data source.
21520
+ */
21521
+ static create(options) {
21522
+ return (options?.client ?? client).post({
21523
+ responseTransformer: chatThreadCreateResponseTransformer,
21524
+ url: "/ChatThreads",
21525
+ ...options,
21526
+ headers: {
21527
+ "Content-Type": "application/json",
21528
+ ...options?.headers
21529
+ }
21530
+ });
21531
+ }
21532
+ /**
21533
+ * Replace an existing model instance or insert a new one into the data source.
21534
+ */
21535
+ static replaceOrCreatePutChatThreads(options) {
21536
+ return (options?.client ?? client).put({
21537
+ responseTransformer: chatThreadReplaceOrCreatePutChatThreadsResponseTransformer,
21538
+ url: "/ChatThreads",
21539
+ ...options,
21540
+ headers: {
21541
+ "Content-Type": "application/json",
21542
+ ...options?.headers
21543
+ }
21544
+ });
21545
+ }
21546
+ /**
21547
+ * Replace an existing model instance or insert a new one into the data source.
21548
+ */
21549
+ static replaceOrCreatePostChatThreadsReplaceOrCreate(options) {
21550
+ return (options?.client ?? client).post({
21551
+ responseTransformer: chatThreadReplaceOrCreatePostChatThreadsReplaceOrCreateResponseTransformer,
21552
+ url: "/ChatThreads/replaceOrCreate",
21553
+ ...options,
21554
+ headers: {
21555
+ "Content-Type": "application/json",
21556
+ ...options?.headers
21557
+ }
21558
+ });
21559
+ }
21560
+ /**
21561
+ * Update an existing model instance or insert a new one into the data source based on the where criteria.
21562
+ */
21563
+ static upsertWithWhere(options) {
21564
+ return (options?.client ?? client).post({
21565
+ responseTransformer: chatThreadUpsertWithWhereResponseTransformer,
21566
+ url: "/ChatThreads/upsertWithWhere",
21567
+ ...options,
21568
+ headers: {
21569
+ "Content-Type": "application/json",
21570
+ ...options?.headers
21571
+ }
21572
+ });
21573
+ }
21574
+ /**
21575
+ * Check whether a model instance exists in the data source.
21576
+ */
21577
+ static existsGetChatThreadsIdExists(options) {
21578
+ return (options.client ?? client).get({
21579
+ url: "/ChatThreads/{id}/exists",
21580
+ ...options
21581
+ });
21582
+ }
21583
+ /**
21584
+ * Delete a model instance by {{id}} from the data source.
21585
+ */
21586
+ static deleteById(options) {
21587
+ return (options.client ?? client).delete({
21588
+ url: "/ChatThreads/{id}",
21589
+ ...options
21590
+ });
21591
+ }
21592
+ /**
21593
+ * Find a model instance by {{id}} from the data source.
21594
+ */
21595
+ static findById(options) {
21596
+ return (options.client ?? client).get({
21597
+ responseTransformer: chatThreadFindByIdResponseTransformer,
21598
+ url: "/ChatThreads/{id}",
21599
+ ...options
21600
+ });
21601
+ }
21602
+ /**
21603
+ * Check whether a model instance exists in the data source.
21604
+ */
21605
+ static existsHeadChatThreadsId(options) {
21606
+ return (options.client ?? client).head({
21607
+ url: "/ChatThreads/{id}",
21608
+ ...options
21609
+ });
21610
+ }
21611
+ /**
21612
+ * Patch attributes for a model instance and persist it into the data source.
21613
+ */
21614
+ static prototypePatchAttributes(options) {
21615
+ return (options.client ?? client).patch({
21616
+ responseTransformer: chatThreadPrototypePatchAttributesResponseTransformer,
21617
+ url: "/ChatThreads/{id}",
21618
+ ...options,
21619
+ headers: {
21620
+ "Content-Type": "application/json",
21621
+ ...options.headers
21622
+ }
21623
+ });
21624
+ }
21625
+ /**
21626
+ * Replace attributes for a model instance and persist it into the data source.
21627
+ */
21628
+ static replaceByIdPutChatThreadsId(options) {
21629
+ return (options.client ?? client).put({
21630
+ responseTransformer: chatThreadReplaceByIdPutChatThreadsIdResponseTransformer,
21631
+ url: "/ChatThreads/{id}",
21632
+ ...options,
21633
+ headers: {
21634
+ "Content-Type": "application/json",
21635
+ ...options.headers
21636
+ }
21637
+ });
21638
+ }
21639
+ /**
21640
+ * Replace attributes for a model instance and persist it into the data source.
21641
+ */
21642
+ static replaceByIdPostChatThreadsIdReplace(options) {
21643
+ return (options.client ?? client).post({
21644
+ responseTransformer: chatThreadReplaceByIdPostChatThreadsIdReplaceResponseTransformer,
21645
+ url: "/ChatThreads/{id}/replace",
21646
+ ...options,
21647
+ headers: {
21648
+ "Content-Type": "application/json",
21649
+ ...options.headers
21650
+ }
21651
+ });
21652
+ }
21653
+ /**
21654
+ * Find first instance of the model matched by filter from the data source.
21655
+ */
21656
+ static findOne(options) {
21657
+ return (options?.client ?? client).get({
21658
+ responseTransformer: chatThreadFindOneResponseTransformer,
21659
+ url: "/ChatThreads/findOne",
21660
+ ...options
21661
+ });
21662
+ }
21663
+ /**
21664
+ * Update instances of the model matched by {{where}} from the data source.
21665
+ */
21666
+ static updateAll(options) {
21667
+ return (options?.client ?? client).post({
21668
+ url: "/ChatThreads/update",
21669
+ ...options,
21670
+ headers: {
21671
+ "Content-Type": "application/json",
21672
+ ...options?.headers
21673
+ }
21674
+ });
21675
+ }
21676
+ /**
21677
+ * Count instances of the model matched by where from the data source.
21678
+ */
21679
+ static count(options) {
21680
+ return (options?.client ?? client).get({
21681
+ url: "/ChatThreads/count",
21682
+ ...options
21683
+ });
21684
+ }
21685
+ static getThreads(options) {
21686
+ return (options?.client ?? client).get({
21687
+ url: "/ChatThreads/getThreads",
21688
+ ...options
21689
+ });
21690
+ }
21691
+ static createThread(options) {
21692
+ return (options.client ?? client).post({
21693
+ url: "/ChatThreads/createThread",
21694
+ ...options,
21695
+ headers: {
21696
+ "Content-Type": "application/json",
21697
+ ...options.headers
21698
+ }
21699
+ });
21700
+ }
21701
+ static updateThread(options) {
21702
+ return (options.client ?? client).post({
21703
+ url: "/ChatThreads/updateThread",
21704
+ ...options,
21705
+ headers: {
21706
+ "Content-Type": "application/json",
21707
+ ...options.headers
21708
+ }
21709
+ });
21710
+ }
21711
+ static loadThread(options) {
21712
+ return (options.client ?? client).get({
21713
+ url: "/ChatThreads/loadThread",
21714
+ ...options
21715
+ });
21716
+ }
21717
+ };
21718
+ var CommandPaletteHistoryService = class {
21719
+ /**
21720
+ * Find all instances of the model matched by filter from the data source.
21721
+ */
21722
+ static find(options) {
21723
+ return (options?.client ?? client).get({
21724
+ responseTransformer: commandPaletteHistoryFindResponseTransformer,
21725
+ url: "/CommandPaletteHistories",
21726
+ ...options
21727
+ });
21728
+ }
21729
+ /**
21730
+ * Create a new instance of the model and persist it into the data source.
21731
+ */
21732
+ static create(options) {
21733
+ return (options?.client ?? client).post({
21734
+ responseTransformer: commandPaletteHistoryCreateResponseTransformer,
21735
+ url: "/CommandPaletteHistories",
21736
+ ...options,
21737
+ headers: {
21738
+ "Content-Type": "application/json",
21739
+ ...options?.headers
21740
+ }
21741
+ });
21742
+ }
21743
+ /**
21744
+ * Delete a model instance by {{id}} from the data source.
21745
+ */
21746
+ static deleteById(options) {
21747
+ return (options.client ?? client).delete({
21748
+ url: "/CommandPaletteHistories/{id}",
21749
+ ...options
21750
+ });
21751
+ }
21752
+ /**
21753
+ * Patch attributes for a model instance and persist it into the data source.
21754
+ */
21755
+ static prototypePatchAttributes(options) {
21756
+ return (options.client ?? client).patch({
21757
+ responseTransformer: commandPaletteHistoryPrototypePatchAttributesResponseTransformer,
21758
+ url: "/CommandPaletteHistories/{id}",
21759
+ ...options,
21760
+ headers: {
21761
+ "Content-Type": "application/json",
21762
+ ...options.headers
21763
+ }
21764
+ });
21765
+ }
21766
+ /**
21767
+ * Count instances of the model matched by where from the data source.
21768
+ */
21769
+ static count(options) {
21770
+ return (options?.client ?? client).get({
21771
+ url: "/CommandPaletteHistories/count",
21772
+ ...options
21773
+ });
21774
+ }
21775
+ };
21776
+
21777
+ // src/index.ts
21778
+ var log = (0, import_debug.default)("nextplus:sdk");
21779
+ var accessToken = {
21780
+ token: null,
21781
+ created: null,
21782
+ ttl: 0
21783
+ };
21784
+ var setAccessToken = (token, created = /* @__PURE__ */ new Date(), ttl = 1209600) => {
21785
+ accessToken.token = token;
21786
+ accessToken.created = created;
21787
+ accessToken.ttl = ttl;
21788
+ };
21789
+ var getAccessToken = () => {
21790
+ return accessToken;
21791
+ };
21792
+ var isTokenValid = () => {
21793
+ if (!accessToken.token || !accessToken.created) {
21794
+ return false;
21795
+ }
21796
+ const now = /* @__PURE__ */ new Date();
21797
+ const tokenAge = now.getTime() - accessToken.created.getTime();
21798
+ const tokenTtlMs = accessToken.ttl * 1e3;
21799
+ return tokenAge < tokenTtlMs;
21800
+ };
21801
+ var NextPlusSDK = class {
21802
+ constructor(options) {
21803
+ __publicField(this, "client");
21804
+ // Exposed for tree-shakeable service imports
21805
+ __publicField(this, "credentials");
21806
+ __publicField(this, "providedAccessToken");
21807
+ __publicField(this, "returnType", "data");
21808
+ __publicField(this, "authMode");
21809
+ const hasToken = "accessToken" in options && options.accessToken;
21810
+ const hasPassword = "password" in options && options.password;
21811
+ if (hasToken && hasPassword) {
21812
+ throw new Error(
21813
+ "Provide either accessToken or credentials (email/username + password), not both"
21814
+ );
21815
+ }
21816
+ if (!hasToken && !hasPassword) {
21817
+ throw new Error(
21818
+ "Either accessToken or credentials (email/username + password) must be provided"
21819
+ );
21820
+ }
21821
+ if (hasToken) {
21822
+ this.authMode = "token";
21823
+ this.providedAccessToken = options.accessToken;
21824
+ setAccessToken(this.providedAccessToken, /* @__PURE__ */ new Date(), 1209600);
21825
+ } else {
21826
+ this.authMode = "credentials";
21827
+ const credConfig = options;
21828
+ if (!credConfig.email && !credConfig.username) {
21829
+ throw new Error(
21830
+ "Either email or username must be provided with password"
21831
+ );
21832
+ }
21833
+ if (credConfig.email && credConfig.username) {
21834
+ throw new Error("Provide either email or username, not both");
21835
+ }
21836
+ this.credentials = {
21837
+ email: credConfig.email,
21838
+ username: credConfig.username,
21839
+ password: credConfig.password
21840
+ };
21841
+ }
21842
+ this.returnType = options.returnType || "data";
21843
+ let baseURL = options.baseURL;
21844
+ if (!baseURL) {
21845
+ if (typeof window !== "undefined" && window.location) {
21846
+ baseURL = window.location.origin + "/api";
21847
+ } else {
21848
+ throw new Error("baseURL is required in non-browser environments");
21849
+ }
21850
+ }
21851
+ if (baseURL.endsWith("/")) {
21852
+ baseURL = baseURL.slice(0, -1);
21853
+ }
21854
+ if (!baseURL.endsWith("/api")) {
21855
+ baseURL = baseURL + "/api";
21856
+ }
21857
+ this.client = createClient(
21858
+ createConfig({
21859
+ baseUrl: baseURL,
21860
+ throwOnError: options.throwOnError ?? false
21861
+ })
21862
+ );
21863
+ this.client.interceptors.request.use(
21864
+ this.authRequestInterceptor.bind(this)
21865
+ );
21866
+ this.createServiceProxies();
21867
+ }
21868
+ // Wrap plain developer inputs into the right container (body/query)
21869
+ // and stringify complex query params when required by LoopBack (filter/where)
21870
+ normalizeOptions(methodName, rawOptions) {
21871
+ const options = rawOptions && typeof rawOptions === "object" ? { ...rawOptions } : {};
21872
+ const method = methodName.toString().toLowerCase();
21873
+ const isFind = method.includes("find") && !method.includes("count");
21874
+ const isCount = method.includes("count");
21875
+ const shouldUseBody = /(create|update|replace|patch|login|upsert)/i.test(
21876
+ methodName.toString()
21877
+ );
21878
+ const topLevelKeys = [
21879
+ "filter",
21880
+ "where",
21881
+ "fields",
21882
+ "order",
21883
+ "limit",
21884
+ "offset",
21885
+ "include"
21886
+ ];
21887
+ const hasTopLevelFilterBits = topLevelKeys.some(
21888
+ (k) => Object.prototype.hasOwnProperty.call(options, k)
21889
+ );
21890
+ if (isFind) {
21891
+ options.query = options.query || {};
21892
+ if (options.filter && typeof options.filter === "object") {
21893
+ options.query.filter = JSON.stringify(options.filter);
21894
+ delete options.filter;
21895
+ } else if (hasTopLevelFilterBits) {
21896
+ const filterObject = {};
21897
+ if (options.where !== void 0) filterObject.where = options.where;
21898
+ if (options.fields !== void 0) filterObject.fields = options.fields;
21899
+ if (options.order !== void 0) filterObject.order = options.order;
21900
+ if (options.limit !== void 0) filterObject.limit = options.limit;
21901
+ if (options.offset !== void 0) filterObject.offset = options.offset;
21902
+ if (options.include !== void 0)
21903
+ filterObject.include = options.include;
21904
+ if (Object.keys(filterObject).length > 0) {
21905
+ options.query.filter = typeof filterObject === "string" ? filterObject : JSON.stringify(filterObject);
21906
+ }
21907
+ topLevelKeys.forEach((k) => delete options[k]);
21908
+ }
21909
+ } else if (isCount) {
21910
+ options.query = options.query || {};
21911
+ if (options.where !== void 0) {
21912
+ const whereVal = options.where;
21913
+ options.query.where = typeof whereVal === "string" ? whereVal : JSON.stringify(whereVal);
21914
+ delete options.where;
21915
+ }
21916
+ } else if (shouldUseBody) {
21917
+ if (options.body === void 0) {
21918
+ const bodyCandidate = { ...options };
21919
+ delete bodyCandidate.client;
21920
+ delete bodyCandidate.query;
21921
+ delete bodyCandidate.path;
21922
+ if (Object.keys(bodyCandidate).length > 0) {
21923
+ options.body = bodyCandidate;
21924
+ Object.keys(options).forEach((k) => {
21925
+ if (!["body", "client", "query", "path"].includes(k))
21926
+ delete options[k];
21927
+ });
21928
+ }
21929
+ }
21930
+ }
21931
+ if (options.query && typeof options.query === "object") {
21932
+ Object.keys(options.query).forEach((key) => {
21933
+ const val = options.query[key];
21934
+ if (val && (Array.isArray(val) || typeof val === "object")) {
21935
+ options.query[key] = JSON.stringify(val);
21936
+ }
21937
+ });
21938
+ }
21939
+ return options;
21940
+ }
21941
+ async authRequestInterceptor(request, _options) {
21942
+ if (request.url.includes("/UserModels/login")) {
21943
+ return request;
21944
+ }
21945
+ if (this.authMode === "token") {
21946
+ if (this.providedAccessToken) {
21947
+ request.headers.set("Authorization", this.providedAccessToken);
21948
+ }
21949
+ } else {
21950
+ await this.ensureValidToken();
21951
+ const token = getAccessToken();
21952
+ if (token.token) {
21953
+ request.headers.set("Authorization", token.token);
21954
+ }
21955
+ }
21956
+ return request;
20864
21957
  }
20865
21958
  async ensureValidToken() {
20866
- if (!isTokenValid()) {
21959
+ if (this.authMode === "credentials" && !isTokenValid()) {
20867
21960
  log("Token expired or missing, refreshing...");
20868
21961
  await this.login();
20869
21962
  }
20870
21963
  }
20871
21964
  async login() {
21965
+ if (this.authMode !== "credentials" || !this.credentials) {
21966
+ throw new Error("Login is only available in credentials mode");
21967
+ }
20872
21968
  try {
20873
21969
  const loginBody = {
20874
21970
  password: this.credentials.password,
@@ -20921,7 +22017,9 @@ var NextPlusSDK = class {
20921
22017
  return result.data;
20922
22018
  }
20923
22019
  if (self.returnType === "data" && result && typeof result === "object" && "error" in result) {
20924
- const error = new Error(result.error.error.message || result.error.error.code || "Unknown error");
22020
+ const error = new Error(
22021
+ result.error.error.message || result.error.error.code || "Unknown error"
22022
+ );
20925
22023
  if (result.error.error.details) {
20926
22024
  error.details = result.error.error.details;
20927
22025
  }
@@ -20934,20 +22032,163 @@ var NextPlusSDK = class {
20934
22032
  }
20935
22033
  });
20936
22034
  }
20937
- // Manual login method (optional, for explicit control)
22035
+ // Manual login method (optional, for explicit control in credentials mode)
20938
22036
  async manualLogin() {
22037
+ if (this.authMode !== "credentials") {
22038
+ throw new Error("manualLogin is only available in credentials mode");
22039
+ }
20939
22040
  return this.login();
20940
22041
  }
22042
+ // Bind a service to this SDK's client for tree-shakeable imports
22043
+ // This eliminates the need to pass client on every call
22044
+ service(ServiceClass) {
22045
+ const client2 = this.client;
22046
+ const boundService = Object.create(ServiceClass);
22047
+ const properties = Object.getOwnPropertyNames(ServiceClass);
22048
+ properties.forEach((key) => {
22049
+ const descriptor = Object.getOwnPropertyDescriptor(ServiceClass, key);
22050
+ if (descriptor && typeof descriptor.value === "function" && key !== "constructor") {
22051
+ boundService[key] = (options = {}) => {
22052
+ return descriptor.value.call(ServiceClass, { ...options, client: client2 });
22053
+ };
22054
+ }
22055
+ });
22056
+ return boundService;
22057
+ }
20941
22058
  };
20942
22059
  var configure = (options) => {
20943
- return new NextPlusSDK(options);
22060
+ const sdk = new NextPlusSDK(options);
22061
+ setDefaultClient(sdk.client);
22062
+ Object.assign(client, sdk.client);
22063
+ return sdk;
20944
22064
  };
20945
22065
  var createSDK = (options) => {
20946
- return new NextPlusSDK(options);
20947
- };
22066
+ const sdk = new NextPlusSDK(options);
22067
+ setDefaultClient(sdk.client);
22068
+ Object.assign(client, sdk.client);
22069
+ return sdk;
22070
+ };
22071
+ var globalClient = null;
22072
+ function setDefaultClient(client2) {
22073
+ globalClient = client2;
22074
+ }
22075
+ function getDefaultClient() {
22076
+ return globalClient;
22077
+ }
22078
+ function clearDefaultClient() {
22079
+ globalClient = null;
22080
+ }
20948
22081
  // Annotate the CommonJS export names for ESM import in node:
20949
22082
  0 && (module.exports = {
22083
+ AclService,
22084
+ AddonService,
22085
+ AiPromptService,
22086
+ AiService,
22087
+ ApiMethodLogService,
22088
+ ApiMethodService,
22089
+ BomService,
22090
+ BreakService,
22091
+ BreakTypeService,
22092
+ CatalogService,
22093
+ CategoryService,
22094
+ CertificateMappingService,
22095
+ CertificateService,
22096
+ ChapterService,
22097
+ ChatThreadService,
22098
+ CommandPaletteHistoryService,
22099
+ CommentService,
22100
+ ConfigurationService,
22101
+ ConnectionService,
22102
+ ConnectorFunctionService,
22103
+ ConnectorService,
22104
+ ContainerService,
22105
+ ContentPackageService,
22106
+ ContentPackageSessionService,
22107
+ ContentPackageViewService,
22108
+ CustomFieldService,
22109
+ DeviceFamilyService,
22110
+ DeviceService,
22111
+ DigestEmailService,
22112
+ DocumentService,
22113
+ EventService,
22114
+ FieldService,
22115
+ FileParserJobService,
22116
+ FileParserService,
22117
+ FileParserStrategyJobService,
22118
+ FolderService,
22119
+ FormDataCommentService,
22120
+ FormDataService,
22121
+ FormService,
22122
+ ForumService,
22123
+ GatewayService,
22124
+ GroupService,
22125
+ IntegrationBuilderService,
22126
+ InventoryTransactionService,
22127
+ LastSeenResourceService,
22128
+ ListItemService,
22129
+ ListService,
22130
+ LocationService,
22131
+ MenusService,
20950
22132
  NextPlusSDK,
22133
+ NodeService,
22134
+ NpsService,
22135
+ OpcUaServerService,
22136
+ OperationService,
22137
+ PagesService,
22138
+ PartAssemblyDocumentService,
22139
+ PartAssemblyService,
22140
+ PartService,
22141
+ PostService,
22142
+ PrintPresetService,
22143
+ PriorityLabelService,
22144
+ PriorityService,
22145
+ ProductionEntityEventService,
22146
+ ProductionEntityService,
22147
+ ProductionEntityTransactionService,
22148
+ ProductionEntityTypeService,
22149
+ ProjectService,
22150
+ ResourceService,
22151
+ RevisionService,
22152
+ RoleService,
22153
+ RuleService,
22154
+ ScromSessionService,
22155
+ SettingService,
22156
+ ShiftService,
22157
+ ShiftTypeService,
22158
+ SqlServerService,
22159
+ StationService,
22160
+ StockService,
22161
+ SyncClientsService,
22162
+ SyncHistoryService,
22163
+ SyncService,
22164
+ TableService,
22165
+ TableSetupService,
22166
+ TimeLogReportService,
22167
+ TimelineService,
22168
+ ToolExecutionResultService,
22169
+ ToolService,
22170
+ TranslationService,
22171
+ UnitService,
22172
+ UpdateInfoService,
22173
+ UserModelService,
22174
+ VariantService,
22175
+ VoteMappingService,
22176
+ WarehouseService,
22177
+ WebhookService,
22178
+ WireService,
22179
+ WiringlistService,
22180
+ WorkflowDetailsService,
22181
+ WorkflowService,
22182
+ WorkflowSessionItemRecordService,
22183
+ WorkflowSessionItemService,
22184
+ WorkflowTypeService,
22185
+ WorkorderService,
22186
+ WorkorderStatusService,
22187
+ WorkorderStatusTransitionService,
22188
+ WorkorderTemplateService,
22189
+ clearDefaultClient,
20951
22190
  configure,
20952
- createSDK
22191
+ createSDK,
22192
+ getDefaultClient,
22193
+ setDefaultClient
20953
22194
  });