@squidcloud/client 1.0.157 → 1.0.159

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 (96) hide show
  1. package/dist/cjs/index.js +146 -66
  2. package/package.json +1 -1
  3. package/dist/internal-common/src/public-types/ai-assistant.types.d.ts +0 -25
  4. package/dist/internal-common/src/public-types/ai-chatbot.context.d.ts +0 -12
  5. package/dist/internal-common/src/public-types/ai-chatbot.types.d.ts +0 -29
  6. package/dist/internal-common/src/public-types/api-call.context.d.ts +0 -13
  7. package/dist/internal-common/src/public-types/api.types.d.ts +0 -4
  8. package/dist/internal-common/src/public-types/application.types.d.ts +0 -147
  9. package/dist/internal-common/src/public-types/backend-run.types.d.ts +0 -2
  10. package/dist/internal-common/src/public-types/base-query-builder.d.ts +0 -147
  11. package/dist/internal-common/src/public-types/bundle-api.types.d.ts +0 -47
  12. package/dist/internal-common/src/public-types/bundle-data.types.d.ts +0 -9
  13. package/dist/internal-common/src/public-types/communication.types.d.ts +0 -10
  14. package/dist/internal-common/src/public-types/context.types.d.ts +0 -40
  15. package/dist/internal-common/src/public-types/distributed-lock.context.d.ts +0 -4
  16. package/dist/internal-common/src/public-types/document.types.d.ts +0 -22
  17. package/dist/internal-common/src/public-types/graphql.context.d.ts +0 -7
  18. package/dist/internal-common/src/public-types/graphql.types.d.ts +0 -9
  19. package/dist/internal-common/src/public-types/heartbeat.types.d.ts +0 -1
  20. package/dist/internal-common/src/public-types/http-status.enum.d.ts +0 -50
  21. package/dist/internal-common/src/public-types/integration-types.d.ts +0 -57
  22. package/dist/internal-common/src/public-types/integrations/ai_chatbot.types.d.ts +0 -32
  23. package/dist/internal-common/src/public-types/integrations/api.types.d.ts +0 -81
  24. package/dist/internal-common/src/public-types/integrations/auth.types.d.ts +0 -48
  25. package/dist/internal-common/src/public-types/integrations/database.types.d.ts +0 -275
  26. package/dist/internal-common/src/public-types/integrations/observability.types.d.ts +0 -24
  27. package/dist/internal-common/src/public-types/integrations/schemas.d.ts +0 -73
  28. package/dist/internal-common/src/public-types/logger.types.d.ts +0 -21
  29. package/dist/internal-common/src/public-types/metrics.types.d.ts +0 -1
  30. package/dist/internal-common/src/public-types/mutation.context.d.ts +0 -14
  31. package/dist/internal-common/src/public-types/mutation.types.d.ts +0 -53
  32. package/dist/internal-common/src/public-types/native-query.context.d.ts +0 -7
  33. package/dist/internal-common/src/public-types/native-query.types.d.ts +0 -16
  34. package/dist/internal-common/src/public-types/openapi.types.d.ts +0 -1
  35. package/dist/internal-common/src/public-types/pagination.d.ts +0 -62
  36. package/dist/internal-common/src/public-types/query-context.d.ts +0 -137
  37. package/dist/internal-common/src/public-types/query.types.d.ts +0 -64
  38. package/dist/internal-common/src/public-types/regions.d.ts +0 -1
  39. package/dist/internal-common/src/public-types/secret.types.d.ts +0 -22
  40. package/dist/internal-common/src/public-types/serialized-query.types.d.ts +0 -24
  41. package/dist/internal-common/src/public-types/socket.types.d.ts +0 -5
  42. package/dist/internal-common/src/public-types/types.d.ts +0 -14
  43. package/dist/internal-common/src/public-utils/id-utils.d.ts +0 -4
  44. package/dist/internal-common/src/schema/schema.types.d.ts +0 -54
  45. package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
  46. package/dist/internal-common/src/utils/array.d.ts +0 -1
  47. package/dist/internal-common/src/utils/assert.d.ts +0 -1
  48. package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
  49. package/dist/internal-common/src/utils/http.d.ts +0 -2
  50. package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
  51. package/dist/internal-common/src/utils/object.d.ts +0 -5
  52. package/dist/internal-common/src/utils/serialization.d.ts +0 -5
  53. package/dist/internal-common/src/utils/validation.d.ts +0 -27
  54. package/dist/internal-common/src/websocket.impl.d.ts +0 -21
  55. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +0 -1239
  56. package/dist/typescript-client/src/ai-assistant-client.d.ts +0 -73
  57. package/dist/typescript-client/src/ai-chatbot-client.d.ts +0 -174
  58. package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +0 -8
  59. package/dist/typescript-client/src/ai.types.d.ts +0 -63
  60. package/dist/typescript-client/src/api.manager.d.ts +0 -11
  61. package/dist/typescript-client/src/auth.manager.d.ts +0 -27
  62. package/dist/typescript-client/src/backend-function.manager.d.ts +0 -9
  63. package/dist/typescript-client/src/backend-transforms.d.ts +0 -0
  64. package/dist/typescript-client/src/client-id.service.d.ts +0 -27
  65. package/dist/typescript-client/src/collection-reference.d.ts +0 -80
  66. package/dist/typescript-client/src/collection-reference.factory.d.ts +0 -13
  67. package/dist/typescript-client/src/connection-details.d.ts +0 -23
  68. package/dist/typescript-client/src/data.manager.d.ts +0 -175
  69. package/dist/typescript-client/src/destruct.manager.d.ts +0 -12
  70. package/dist/typescript-client/src/distributed-lock.manager.d.ts +0 -16
  71. package/dist/typescript-client/src/document-identity.service.d.ts +0 -12
  72. package/dist/typescript-client/src/document-reference.d.ts +0 -148
  73. package/dist/typescript-client/src/document-reference.factory.d.ts +0 -13
  74. package/dist/typescript-client/src/document-store.d.ts +0 -14
  75. package/dist/typescript-client/src/graphql-client.d.ts +0 -14
  76. package/dist/typescript-client/src/graphql-client.factory.d.ts +0 -11
  77. package/dist/typescript-client/src/index.d.ts +0 -11
  78. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +0 -11
  79. package/dist/typescript-client/src/native-query-manager.d.ts +0 -7
  80. package/dist/typescript-client/src/public-types.d.ts +0 -40
  81. package/dist/typescript-client/src/public-utils.d.ts +0 -1
  82. package/dist/typescript-client/src/query/deserializer.d.ts +0 -3
  83. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +0 -161
  84. package/dist/typescript-client/src/query/local-query-manager.d.ts +0 -9
  85. package/dist/typescript-client/src/query/query-builder.factory.d.ts +0 -77
  86. package/dist/typescript-client/src/query/query-sender.d.ts +0 -33
  87. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +0 -131
  88. package/dist/typescript-client/src/query/query.types.d.ts +0 -49
  89. package/dist/typescript-client/src/rate-limiter.d.ts +0 -32
  90. package/dist/typescript-client/src/rpc.manager.d.ts +0 -30
  91. package/dist/typescript-client/src/secret.client.d.ts +0 -22
  92. package/dist/typescript-client/src/socket.manager.d.ts +0 -43
  93. package/dist/typescript-client/src/squid.d.ts +0 -238
  94. package/dist/typescript-client/src/state/state.service.spec.d.ts +0 -1
  95. package/dist/typescript-client/src/testing/setup-tests.d.ts +0 -1
  96. package/dist/typescript-client/src/types.d.ts +0 -2
package/dist/cjs/index.js CHANGED
@@ -27924,10 +27924,7 @@ __webpack_require__.r(__webpack_exports__);
27924
27924
  __webpack_require__.d(__webpack_exports__, {
27925
27925
  AI_MODEL_NAMES: () => (/* reexport */ AI_MODEL_NAMES),
27926
27926
  APP_API_KEY: () => (/* reexport */ APP_API_KEY),
27927
- AiChatbotChatContext: () => (/* reexport */ AiChatbotChatContext),
27928
- AiChatbotMutationContext: () => (/* reexport */ AiChatbotMutationContext),
27929
27927
  AiChatbotProfileReference: () => (/* reexport */ AiChatbotProfileReference),
27930
- AiModelData: () => (/* reexport */ AiModelData),
27931
27928
  ApiCallContext: () => (/* reexport */ ApiCallContext),
27932
27929
  ApiIntegrationTypes: () => (/* reexport */ ApiIntegrationTypes),
27933
27930
  AuthIntegrationTypes: () => (/* reexport */ AuthIntegrationTypes),
@@ -27937,6 +27934,7 @@ __webpack_require__.d(__webpack_exports__, {
27937
27934
  ClientConnectionState: () => (/* reexport */ ClientConnectionState),
27938
27935
  CollectionReference: () => (/* reexport */ CollectionReference),
27939
27936
  CronExpression: () => (/* reexport */ CronExpression),
27937
+ DEFAULT_SHORT_ID_LENGTH: () => (/* reexport */ DEFAULT_SHORT_ID_LENGTH),
27940
27938
  DatabaseIntegrationTypes: () => (/* reexport */ DatabaseIntegrationTypes),
27941
27939
  DistributedLockContext: () => (/* reexport */ DistributedLockContext),
27942
27940
  DocumentReference: () => (/* reexport */ DocumentReference),
@@ -27958,6 +27956,8 @@ __webpack_require__.d(__webpack_exports__, {
27958
27956
  QueryBuilder: () => (/* reexport */ QueryBuilder),
27959
27957
  QueryContext: () => (/* reexport */ QueryContext),
27960
27958
  QueryMappingManager: () => (/* reexport */ QueryMappingManager),
27959
+ QueueIntegrationTypes: () => (/* reexport */ QueueIntegrationTypes),
27960
+ SQUID_CLOUD_IDS: () => (/* reexport */ SQUID_CLOUD_IDS),
27961
27961
  Squid: () => (/* reexport */ Squid),
27962
27962
  SquidPlaceholderId: () => (/* reexport */ SquidPlaceholderId),
27963
27963
  SupportedSquidRegions: () => (/* reexport */ SupportedSquidRegions),
@@ -28000,30 +28000,7 @@ __webpack_require__.d(__webpack_exports__, {
28000
28000
  verifyWithSquidDevId: () => (/* reexport */ verifyWithSquidDevId)
28001
28001
  });
28002
28002
 
28003
- ;// CONCATENATED MODULE: ../internal-common/src/public-types/ai-chatbot.context.ts
28004
- class AiChatbotChatContext {
28005
- /**
28006
- * @internal
28007
- */
28008
- constructor(request) {
28009
- this.profileId = request.profileId;
28010
- this.prompt = request.prompt;
28011
- }
28012
- }
28013
- /** A context provided to the security rules of an AI Chatbot mutation. */
28014
- class AiChatbotMutationContext {
28015
- /**
28016
- * @internal
28017
- */
28018
- constructor(request) {
28019
- this.profileId = request.profileId;
28020
- this.type = request.type;
28021
- this.resource = request.resource;
28022
- this.payload = request.payload;
28023
- }
28024
- }
28025
-
28026
- ;// CONCATENATED MODULE: ../internal-common/src/public-types/ai-chatbot.types.ts
28003
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/ai-chatbot.public-types.ts
28027
28004
  /** The supported AI model names. */
28028
28005
  const AI_MODEL_NAMES = [
28029
28006
  'gpt-3.5-turbo',
@@ -28032,24 +28009,6 @@ const AI_MODEL_NAMES = [
28032
28009
  'claude-2',
28033
28010
  'gpt-4-1106-preview',
28034
28011
  ];
28035
- /** @internal */
28036
- const AiModelData = {
28037
- 'gpt-4': {
28038
- tokens: 8192,
28039
- },
28040
- 'gpt-3.5-turbo': {
28041
- tokens: 4096,
28042
- },
28043
- 'gpt-3.5-turbo-1106': {
28044
- tokens: 16385,
28045
- },
28046
- 'claude-2': {
28047
- tokens: 100000,
28048
- },
28049
- 'gpt-4-1106-preview': {
28050
- tokens: 8192,
28051
- },
28052
- };
28053
28012
 
28054
28013
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/api-call.context.ts
28055
28014
  /** The context of an API call. */
@@ -28176,6 +28135,8 @@ const ExecuteFunctionSecureAnnotations = [
28176
28135
  'secureApi',
28177
28136
  'secureAiChatbotChat',
28178
28137
  'secureAiChatbotMutation',
28138
+ 'secureQueueWrite',
28139
+ 'secureQueueRead',
28179
28140
  ];
28180
28141
  function convertToRunSecrets(appSecrets) {
28181
28142
  const result = {
@@ -28608,6 +28569,7 @@ var http_status_enum_HttpStatus;
28608
28569
  var IntegrationCategory;
28609
28570
  (function (IntegrationCategory) {
28610
28571
  IntegrationCategory["database"] = "database";
28572
+ IntegrationCategory["queue"] = "queue";
28611
28573
  IntegrationCategory["api"] = "api";
28612
28574
  IntegrationCategory["observability"] = "observability";
28613
28575
  IntegrationCategory["crm"] = "crm";
@@ -28633,6 +28595,9 @@ var IntegrationType;
28633
28595
  IntegrationType["ai_chatbot"] = "ai_chatbot";
28634
28596
  IntegrationType["cognito"] = "cognito";
28635
28597
  IntegrationType["okta"] = "okta";
28598
+ IntegrationType["descope"] = "descope";
28599
+ IntegrationType["kafka"] = "kafka";
28600
+ IntegrationType["built_in_queue"] = "built_in_queue";
28636
28601
  // Coming Soon
28637
28602
  IntegrationType["algolia"] = "algolia";
28638
28603
  IntegrationType["elastic_observability"] = "elastic_observability";
@@ -28711,7 +28676,9 @@ const AuthIntegrationTypes = [
28711
28676
  IntegrationType.jwt_hmac,
28712
28677
  IntegrationType.cognito,
28713
28678
  IntegrationType.okta,
28679
+ IntegrationType.descope,
28714
28680
  ];
28681
+ const QueueIntegrationTypes = [IntegrationType.built_in_queue, IntegrationType.kafka];
28715
28682
  function isDataIntegrationType(type) {
28716
28683
  return DatabaseIntegrationTypes.includes(type);
28717
28684
  }
@@ -29644,6 +29611,8 @@ class QueryContext {
29644
29611
 
29645
29612
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/regions.ts
29646
29613
 
29614
+ /** @internal */
29615
+ const SQUID_CLOUD_IDS = ['aws', 'gcp', 'azure'];
29647
29616
  /**
29648
29617
  * The list of supported Squid regions.
29649
29618
  * @internal
@@ -29745,6 +29714,7 @@ var ClientConnectionState;
29745
29714
 
29746
29715
 
29747
29716
 
29717
+
29748
29718
 
29749
29719
 
29750
29720
  ;// CONCATENATED MODULE: ../internal-common/src/public-utils/id-utils.ts
@@ -29757,8 +29727,10 @@ function generateId() {
29757
29727
  return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
29758
29728
  });
29759
29729
  }
29730
+ /** Default length if ID produced by `generateShortId`. */
29731
+ const DEFAULT_SHORT_ID_LENGTH = 18;
29760
29732
  /** Generates an ID of the given `length` using lowercase latin letters and digits.. */
29761
- function generateShortId(length = 18) {
29733
+ function generateShortId(length = DEFAULT_SHORT_ID_LENGTH) {
29762
29734
  const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
29763
29735
  let id = '';
29764
29736
  for (let i = 0; i < length; i++) {
@@ -30836,7 +30808,7 @@ class AiChatbotProfileReference {
30836
30808
  return new AiChatbotInstructionReference(this.client, this.integrationId, this.profileId, id);
30837
30809
  }
30838
30810
  /**
30839
- * Adds a new profile to the chat bot. This will result in an error if a profile already exists with the same id.
30811
+ * Adds a new profile to the chatbot. This will result in an error if a profile already exists with the same id.
30840
30812
  *
30841
30813
  * @param data An object containing options for creating the profile.
30842
30814
  * @param data.modelName - The name of the OpenAI model (`gpt-3.5, `gpt-4` or `claude-2`).
@@ -45711,12 +45683,14 @@ const kotlinControllers = [
45711
45683
  'native-query',
45712
45684
  'application-kotlin',
45713
45685
  'openapi',
45686
+ 'secret',
45687
+ 'queue',
45714
45688
  ];
45715
45689
  function getApplicationUrl(regionPrefix, appId, path) {
45716
45690
  const baseUrl = 'https://squid.cloud';
45717
45691
  const parsedBaseUrl = new URL(baseUrl);
45718
45692
  parsedBaseUrl.host = `${appId}.${regionPrefix}.${parsedBaseUrl.host}`;
45719
- const controller = path.split('/')[0] || '';
45693
+ const controller = path.replace(/^\//g, '').split('/')[0] || '';
45720
45694
  if (isLocal(regionPrefix)) {
45721
45695
  parsedBaseUrl.protocol = 'http';
45722
45696
  parsedBaseUrl.port = kotlinControllers.includes(controller) ? '8001' : '8000';
@@ -46757,7 +46731,7 @@ const UNSET_VALUE = Symbol('undefined');
46757
46731
 
46758
46732
  class DestructManager {
46759
46733
  constructor() {
46760
- this.predestructors = [];
46734
+ this.preDestructors = [];
46761
46735
  this.destructors = [];
46762
46736
  this.isDestructedSubject = new external_rxjs_.BehaviorSubject(false);
46763
46737
  }
@@ -46768,17 +46742,14 @@ class DestructManager {
46768
46742
  return this.isDestructedSubject.asObservable().pipe((0,external_rxjs_.filter)(Boolean), map(() => undefined));
46769
46743
  }
46770
46744
  onPreDestruct(fn) {
46771
- this.predestructors.push(fn);
46745
+ this.preDestructors.push(fn);
46772
46746
  }
46773
46747
  onDestruct(fn) {
46774
46748
  this.destructors.push(fn);
46775
46749
  }
46776
46750
  async destruct() {
46777
- if (this.isDestructing) {
46778
- return;
46779
- }
46780
- this.isDestructedSubject.next(true);
46781
- const fns = this.predestructors.concat(this.destructors);
46751
+ this.reportDestructed();
46752
+ const fns = this.preDestructors.concat(this.destructors);
46782
46753
  let fn = fns.shift();
46783
46754
  while (fn) {
46784
46755
  try {
@@ -46790,6 +46761,12 @@ class DestructManager {
46790
46761
  fn = fns.shift();
46791
46762
  }
46792
46763
  }
46764
+ reportDestructed() {
46765
+ if (this.isDestructing) {
46766
+ return;
46767
+ }
46768
+ this.isDestructedSubject.next(true);
46769
+ }
46793
46770
  }
46794
46771
 
46795
46772
  ;// CONCATENATED MODULE: ./src/distributed-lock.manager.ts
@@ -48338,25 +48315,25 @@ class SecretClient {
48338
48315
  }
48339
48316
  async get(key) {
48340
48317
  const request = { key };
48341
- return (await this.rpcManager.post('/secret/get', request)) || undefined;
48318
+ return (await this.rpcManager.post('secret/get', request)) || undefined;
48342
48319
  }
48343
48320
  getAll() {
48344
- return this.rpcManager.post('/secret/getAll', {});
48321
+ return this.rpcManager.post('secret/getAll', {});
48345
48322
  }
48346
48323
  upsert(key, value) {
48347
48324
  return this.upsertMany([{ key, value }]).then(entries => entries[0]);
48348
48325
  }
48349
48326
  upsertMany(entries) {
48350
48327
  const request = { entries };
48351
- return this.rpcManager.post('/secret/upsert', request);
48328
+ return this.rpcManager.post('secret/upsert', request);
48352
48329
  }
48353
48330
  delete(key) {
48354
48331
  const request = { keys: [key] };
48355
- return this.rpcManager.post('/secret/delete', request);
48332
+ return this.rpcManager.post('secret/delete', request);
48356
48333
  }
48357
48334
  deleteMany(keys) {
48358
48335
  const request = { keys };
48359
- return this.rpcManager.post('/secret/delete', request);
48336
+ return this.rpcManager.post('secret/delete', request);
48360
48337
  }
48361
48338
  get apiKeys() {
48362
48339
  return new ApiKeysSecretClient(this.rpcManager);
@@ -48368,18 +48345,18 @@ class ApiKeysSecretClient {
48368
48345
  }
48369
48346
  get(key) {
48370
48347
  const request = { key };
48371
- return this.rpcManager.post('/secret/api-key/get', request);
48348
+ return this.rpcManager.post('secret/api-key/get', request);
48372
48349
  }
48373
48350
  getAll() {
48374
- return this.rpcManager.post('/secret/api-key/getAll', {});
48351
+ return this.rpcManager.post('secret/api-key/getAll', {});
48375
48352
  }
48376
48353
  upsert(key) {
48377
48354
  const request = { key };
48378
- return this.rpcManager.post('/secret/api-key/upsert', request);
48355
+ return this.rpcManager.post('secret/api-key/upsert', request);
48379
48356
  }
48380
48357
  delete(key) {
48381
48358
  const request = { key };
48382
- return this.rpcManager.post('/secret/api-key/delete', request);
48359
+ return this.rpcManager.post('secret/api-key/delete', request);
48383
48360
  }
48384
48361
  }
48385
48362
 
@@ -48993,6 +48970,101 @@ class LockManager {
48993
48970
  }
48994
48971
  }
48995
48972
 
48973
+ ;// CONCATENATED MODULE: ./src/queue.manager.ts
48974
+
48975
+ /** @internal */
48976
+ class QueueManagerFactory {
48977
+ constructor(rpcManager, socketManager, destructManager) {
48978
+ this.rpcManager = rpcManager;
48979
+ this.socketManager = socketManager;
48980
+ this.queueManagers = new Map();
48981
+ this.socketManager.observeNotifications().subscribe(message => {
48982
+ const queueManager = this.getOrUndefined(message.integrationId, message.topicName);
48983
+ if (!queueManager) {
48984
+ return;
48985
+ }
48986
+ queueManager.onMessages(message.payload);
48987
+ });
48988
+ destructManager.onPreDestruct(() => {
48989
+ for (const queueManagersForIntegration of this.queueManagers.values()) {
48990
+ for (const queueManager of queueManagersForIntegration.values()) {
48991
+ queueManager.destruct();
48992
+ }
48993
+ }
48994
+ });
48995
+ }
48996
+ get(integrationId, topicName) {
48997
+ let integrationQueueManagers = this.queueManagers.get(integrationId);
48998
+ if (!integrationQueueManagers) {
48999
+ integrationQueueManagers = new Map();
49000
+ this.queueManagers.set(integrationId, integrationQueueManagers);
49001
+ }
49002
+ let queueManager = integrationQueueManagers.get(topicName);
49003
+ if (!queueManager) {
49004
+ queueManager = new QueueManagerImpl(integrationId, topicName, this.rpcManager);
49005
+ integrationQueueManagers.set(topicName, queueManager);
49006
+ }
49007
+ return queueManager;
49008
+ }
49009
+ getOrUndefined(integrationId, topicName) {
49010
+ var _a;
49011
+ return (_a = this.queueManagers.get(integrationId)) === null || _a === void 0 ? void 0 : _a.get(topicName);
49012
+ }
49013
+ }
49014
+ /** @internal */
49015
+ class QueueManagerImpl {
49016
+ constructor(integrationId, topicName, rpcManager) {
49017
+ this.integrationId = integrationId;
49018
+ this.topicName = topicName;
49019
+ this.rpcManager = rpcManager;
49020
+ this.messagesSubject = new external_rxjs_.Subject();
49021
+ this.subscriberCount = 0;
49022
+ }
49023
+ async produce(messages) {
49024
+ await this.rpcManager.post('queue/produceMessages', {
49025
+ integrationId: this.integrationId,
49026
+ topicName: this.topicName,
49027
+ messages,
49028
+ });
49029
+ }
49030
+ consume() {
49031
+ return (0,external_rxjs_.defer)(() => {
49032
+ // Code to run when the observable is subscribed
49033
+ this.subscriberCount++;
49034
+ if (this.subscriberCount === 1) {
49035
+ this.rpcManager
49036
+ .post('queue/subscribe', {
49037
+ integrationId: this.integrationId,
49038
+ topicName: this.topicName,
49039
+ })
49040
+ .catch(e => {
49041
+ this.messagesSubject.error(e);
49042
+ this.messagesSubject.complete();
49043
+ this.subscriberCount = 0;
49044
+ this.messagesSubject = new external_rxjs_.Subject();
49045
+ });
49046
+ }
49047
+ return this.messagesSubject.asObservable().pipe((0,external_rxjs_.finalize)(() => {
49048
+ this.subscriberCount--;
49049
+ if (this.subscriberCount === 0) {
49050
+ this.rpcManager.post('queue/unsubscribe', {
49051
+ integrationId: this.integrationId,
49052
+ topicName: this.topicName,
49053
+ });
49054
+ }
49055
+ }));
49056
+ });
49057
+ }
49058
+ onMessages(payload) {
49059
+ for (const message of payload) {
49060
+ this.messagesSubject.next(message);
49061
+ }
49062
+ }
49063
+ destruct() {
49064
+ this.messagesSubject.complete();
49065
+ }
49066
+ }
49067
+
48996
49068
  ;// CONCATENATED MODULE: ./src/squid.ts
48997
49069
 
48998
49070
 
@@ -49022,6 +49094,7 @@ class LockManager {
49022
49094
 
49023
49095
 
49024
49096
 
49097
+
49025
49098
 
49026
49099
 
49027
49100
  /**
@@ -49080,6 +49153,7 @@ class Squid {
49080
49153
  this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
49081
49154
  this.secretClient = new SecretClient(this.rpcManager);
49082
49155
  this._connectionDetails = new ConnectionDetails(this.clientIdService, this.socketManager);
49156
+ this.queueManagerFactory = new QueueManagerFactory(this.rpcManager, this.socketManager, this.destructManager);
49083
49157
  }
49084
49158
  /**
49085
49159
  * Returns the global Squid instance with the given options, creating a new instance if one with the same options
@@ -49235,6 +49309,14 @@ class Squid {
49235
49309
  this._validateNotDestructed();
49236
49310
  return this.distributedLockManager.lock(mutex);
49237
49311
  }
49312
+ /**
49313
+ * Returns a queue manager for the given topic name and integration id. Using the queue manager you can consume and
49314
+ * produce messages
49315
+ */
49316
+ queue(topicName, integrationId = IntegrationType.built_in_queue) {
49317
+ this._validateNotDestructed();
49318
+ return this.queueManagerFactory.get(integrationId, topicName);
49319
+ }
49238
49320
  /**
49239
49321
  * Destructs the Squid Client. Unsubscribes from all ongoing queries or requests, and clears the local data.
49240
49322
  * After invoking this method, the Squid client will not be usable.
@@ -49242,8 +49324,6 @@ class Squid {
49242
49324
  * @returns A promise that resolves when the destruct process is complete.
49243
49325
  */
49244
49326
  async destruct() {
49245
- if (this.destructManager.isDestructing)
49246
- return;
49247
49327
  return this.destructManager.destruct().finally(() => {
49248
49328
  const entry = Object.entries(Squid.squidInstancesMap).find(([, value]) => value === this);
49249
49329
  if (entry)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.157",
3
+ "version": "1.0.159",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",
@@ -1,25 +0,0 @@
1
- import { FunctionName } from './bundle-data.types';
2
- export type AssistantToolType = 'code_interpreter' | 'retrieval';
3
- export interface CreateAssistantRequest {
4
- name: string;
5
- instructions: string;
6
- functions: Array<FunctionName>;
7
- toolTypes?: Array<AssistantToolType>;
8
- }
9
- export interface DeleteAssistantRequest {
10
- assistantId: string;
11
- }
12
- export interface CreateAssistantThreadRequest {
13
- assistantId: string;
14
- }
15
- export interface DeleteThreadRequest {
16
- threadId: string;
17
- }
18
- export interface CreateAssistantThreadRequest {
19
- }
20
- export interface CreateAssistantResponse {
21
- assistantId: string;
22
- }
23
- export interface CreateAssistantThreadResponse {
24
- threadId: string;
25
- }
@@ -1,12 +0,0 @@
1
- import { AiChatbotMutationType, AiChatbotResourceType } from './ai-chatbot.types';
2
- export declare class AiChatbotChatContext {
3
- readonly prompt: string;
4
- readonly profileId: string;
5
- }
6
- /** A context provided to the security rules of an AI Chatbot mutation. */
7
- export declare class AiChatbotMutationContext {
8
- readonly type: AiChatbotMutationType;
9
- readonly resource: AiChatbotResourceType;
10
- readonly profileId: string;
11
- readonly payload: any;
12
- }
@@ -1,29 +0,0 @@
1
- /** The supported AI model names. */
2
- export declare const AI_MODEL_NAMES: readonly ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-4", "claude-2", "gpt-4-1106-preview"];
3
- export type AiModelName = (typeof AI_MODEL_NAMES)[number];
4
- /** The possible sources for the LLM provider API key. */
5
- export type ApiKeySource = 'user' | 'system';
6
- export type AiChatbotContextType = 'text' | 'url' | 'file';
7
- interface AiChatbotContextBase {
8
- type: AiChatbotContextType;
9
- data: string;
10
- }
11
- export interface AiChatbotTextContext extends AiChatbotContextBase {
12
- type: 'text';
13
- }
14
- export interface AiChatbotUrlContext extends AiChatbotContextBase {
15
- type: 'url';
16
- }
17
- export interface AiChatbotFileContext extends AiChatbotContextBase {
18
- type: 'file';
19
- }
20
- export type AiChatbotContext = AiChatbotTextContext | AiChatbotUrlContext | AiChatbotFileContext;
21
- export type OpenAiResponseFormat = 'text' | 'json_object';
22
- export interface AiChatbotChatOptions {
23
- maxTokens?: number;
24
- chatId?: string;
25
- disableHistory?: boolean;
26
- includeReference?: boolean;
27
- responseFormat?: OpenAiResponseFormat;
28
- }
29
- export {};
@@ -1,13 +0,0 @@
1
- import { ApiHeaders } from './api.types';
2
- import { ApiEndpointId, HttpMethod } from './integrations/api.types';
3
- /** The context of an API call. */
4
- export declare class ApiCallContext {
5
- readonly endpointId: ApiEndpointId;
6
- readonly url: string;
7
- readonly method: HttpMethod;
8
- readonly headers: ApiHeaders;
9
- readonly body: Record<string, any>;
10
- readonly queryParams: Record<string, string | number | boolean>;
11
- readonly pathParams: Record<string, string>;
12
- readonly serverUrlOverride: string | undefined;
13
- }
@@ -1,4 +0,0 @@
1
- /** The headers of an API call. */
2
- export type ApiHeaders = Record<string, string | number | boolean>;
3
- /** The query parameters of an API call. */
4
- export type ApiQueryParams = Record<string, string | number | boolean>;
@@ -1,147 +0,0 @@
1
- import { AppId, EnvironmentId, IntegrationId } from './communication.types';
2
- import { AuthIntegrationType, DatabaseIntegrationType, IntegrationConfig, IntegrationConfigTypes, IntegrationSchema, IntegrationSchemaKeys, IntegrationSchemaTypes, IntegrationTypeWithConfig } from './integrations/schemas';
3
- import { IntegrationType } from './integration-types';
4
- /** A type alias for a string that represents a webhook. */
5
- export type WebhookId = string;
6
- /** A type alias for a string that represents a trigger id. */
7
- export type TriggerId = string;
8
- /** A type alias for a string that represents a scheduler id. */
9
- export type SchedulerId = string;
10
- /** The supported cron expression string. */
11
- export type CronExpressionString = `${string} ${string} ${string} ${string} ${string}` | `${string} ${string} ${string} ${string}`;
12
- /** A set of predefined cron expressions. */
13
- export declare enum CronExpression {
14
- EVERY_SECOND = "* * * * * *",
15
- EVERY_5_SECONDS = "*/5 * * * * *",
16
- EVERY_10_SECONDS = "*/10 * * * * *",
17
- EVERY_30_SECONDS = "*/30 * * * * *",
18
- EVERY_MINUTE = "*/1 * * * *",
19
- EVERY_5_MINUTES = "0 */5 * * * *",
20
- EVERY_10_MINUTES = "0 */10 * * * *",
21
- EVERY_30_MINUTES = "0 */30 * * * *",
22
- EVERY_HOUR = "0 0-23/1 * * *",
23
- EVERY_2_HOURS = "0 0-23/2 * * *",
24
- EVERY_3_HOURS = "0 0-23/3 * * *",
25
- EVERY_4_HOURS = "0 0-23/4 * * *",
26
- EVERY_5_HOURS = "0 0-23/5 * * *",
27
- EVERY_6_HOURS = "0 0-23/6 * * *",
28
- EVERY_7_HOURS = "0 0-23/7 * * *",
29
- EVERY_8_HOURS = "0 0-23/8 * * *",
30
- EVERY_9_HOURS = "0 0-23/9 * * *",
31
- EVERY_10_HOURS = "0 0-23/10 * * *",
32
- EVERY_11_HOURS = "0 0-23/11 * * *",
33
- EVERY_12_HOURS = "0 0-23/12 * * *",
34
- EVERY_DAY_AT_1AM = "0 01 * * *",
35
- EVERY_DAY_AT_2AM = "0 02 * * *",
36
- EVERY_DAY_AT_3AM = "0 03 * * *",
37
- EVERY_DAY_AT_4AM = "0 04 * * *",
38
- EVERY_DAY_AT_5AM = "0 05 * * *",
39
- EVERY_DAY_AT_6AM = "0 06 * * *",
40
- EVERY_DAY_AT_7AM = "0 07 * * *",
41
- EVERY_DAY_AT_8AM = "0 08 * * *",
42
- EVERY_DAY_AT_9AM = "0 09 * * *",
43
- EVERY_DAY_AT_10AM = "0 10 * * *",
44
- EVERY_DAY_AT_11AM = "0 11 * * *",
45
- EVERY_DAY_AT_NOON = "0 12 * * *",
46
- EVERY_DAY_AT_1PM = "0 13 * * *",
47
- EVERY_DAY_AT_2PM = "0 14 * * *",
48
- EVERY_DAY_AT_3PM = "0 15 * * *",
49
- EVERY_DAY_AT_4PM = "0 16 * * *",
50
- EVERY_DAY_AT_5PM = "0 17 * * *",
51
- EVERY_DAY_AT_6PM = "0 18 * * *",
52
- EVERY_DAY_AT_7PM = "0 19 * * *",
53
- EVERY_DAY_AT_8PM = "0 20 * * *",
54
- EVERY_DAY_AT_9PM = "0 21 * * *",
55
- EVERY_DAY_AT_10PM = "0 22 * * *",
56
- EVERY_DAY_AT_11PM = "0 23 * * *",
57
- EVERY_DAY_AT_MIDNIGHT = "0 0 * * *",
58
- EVERY_WEEK = "0 0 * * 7",
59
- EVERY_WEEKDAY = "0 0 * * 1-5",
60
- EVERY_WEEKEND = "0 0 * * 6,7",
61
- EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT = "0 0 1 * *",
62
- EVERY_1ST_DAY_OF_MONTH_AT_NOON = "0 12 1 * *",
63
- EVERY_2ND_HOUR = "0 */2 * * *",
64
- EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM = "0 1-23/2 * * *",
65
- EVERY_2ND_MONTH = "0 0 1 */2 *",
66
- EVERY_QUARTER = "0 0 1 */3 *",
67
- EVERY_6_MONTHS = "0 0 1 */6 *",
68
- EVERY_YEAR = "0 0 1 1 *",
69
- EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM = "0 */30 9-17 * * *",
70
- EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM = "0 */30 9-18 * * *",
71
- EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM = "0 */30 10-19 * * *",
72
- MONDAY_TO_FRIDAY_AT_1AM = "0 0 01 * * 1-5",
73
- MONDAY_TO_FRIDAY_AT_2AM = "0 0 02 * * 1-5",
74
- MONDAY_TO_FRIDAY_AT_3AM = "0 0 03 * * 1-5",
75
- MONDAY_TO_FRIDAY_AT_4AM = "0 0 04 * * 1-5",
76
- MONDAY_TO_FRIDAY_AT_5AM = "0 0 05 * * 1-5",
77
- MONDAY_TO_FRIDAY_AT_6AM = "0 0 06 * * 1-5",
78
- MONDAY_TO_FRIDAY_AT_7AM = "0 0 07 * * 1-5",
79
- MONDAY_TO_FRIDAY_AT_8AM = "0 0 08 * * 1-5",
80
- MONDAY_TO_FRIDAY_AT_9AM = "0 0 09 * * 1-5",
81
- MONDAY_TO_FRIDAY_AT_09_30AM = "0 30 09 * * 1-5",
82
- MONDAY_TO_FRIDAY_AT_10AM = "0 0 10 * * 1-5",
83
- MONDAY_TO_FRIDAY_AT_11AM = "0 0 11 * * 1-5",
84
- MONDAY_TO_FRIDAY_AT_11_30AM = "0 30 11 * * 1-5",
85
- MONDAY_TO_FRIDAY_AT_12PM = "0 0 12 * * 1-5",
86
- MONDAY_TO_FRIDAY_AT_1PM = "0 0 13 * * 1-5",
87
- MONDAY_TO_FRIDAY_AT_2PM = "0 0 14 * * 1-5",
88
- MONDAY_TO_FRIDAY_AT_3PM = "0 0 15 * * 1-5",
89
- MONDAY_TO_FRIDAY_AT_4PM = "0 0 16 * * 1-5",
90
- MONDAY_TO_FRIDAY_AT_5PM = "0 0 17 * * 1-5",
91
- MONDAY_TO_FRIDAY_AT_6PM = "0 0 18 * * 1-5",
92
- MONDAY_TO_FRIDAY_AT_7PM = "0 0 19 * * 1-5",
93
- MONDAY_TO_FRIDAY_AT_8PM = "0 0 20 * * 1-5",
94
- MONDAY_TO_FRIDAY_AT_9PM = "0 0 21 * * 1-5",
95
- MONDAY_TO_FRIDAY_AT_10PM = "0 0 22 * * 1-5",
96
- MONDAY_TO_FRIDAY_AT_11PM = "0 0 23 * * 1-5"
97
- }
98
- export interface DeleteIntegrationRequest {
99
- integrationId: IntegrationId;
100
- }
101
- export interface UpdateAllowedHostsRequest {
102
- allowedHosts: string[];
103
- }
104
- export interface CreateEnvironmentRequest {
105
- sourceAppId: AppId;
106
- environmentId: EnvironmentId;
107
- }
108
- export interface UpdateApplicationCodeRequest {
109
- appId: AppId;
110
- openApiSpecStr?: string;
111
- openApiControllersStr?: string;
112
- }
113
- interface BaseUpsertIntegrationRequest<T extends IntegrationTypeWithConfig, C extends IntegrationConfig> {
114
- id: IntegrationId;
115
- type: T;
116
- config: Partial<C>;
117
- }
118
- type ConfigurationTypes = {
119
- [K in IntegrationTypeWithConfig]: IntegrationConfigTypes[K];
120
- };
121
- type UpsertIntegrationRequests = {
122
- [K in IntegrationTypeWithConfig]: BaseUpsertIntegrationRequest<K, ConfigurationTypes[K]>;
123
- };
124
- export type UpsertDataIntegrationRequest = UpsertIntegrationRequests[DatabaseIntegrationType];
125
- export type UpsertGraphQLIntegrationRequest = UpsertIntegrationRequests[IntegrationType.graphql];
126
- export type UpsertApiIntegrationRequest = UpsertIntegrationRequests[IntegrationType.api];
127
- export type UpsertAiChatbotIntegrationRequest = UpsertIntegrationRequests[IntegrationType.ai_chatbot];
128
- export type UpsertAuthIntegrationRequest = UpsertIntegrationRequests[AuthIntegrationType];
129
- interface BaseUpsertIntegrationSchemaRequest<T extends IntegrationType, S extends IntegrationSchema> {
130
- id: IntegrationId;
131
- type: T;
132
- schema: S;
133
- }
134
- type SchemaTypes = {
135
- [K in IntegrationSchemaKeys]: IntegrationSchemaTypes[K];
136
- };
137
- type UpsertIntegrationSchemaRequests = {
138
- [K in IntegrationSchemaKeys]: BaseUpsertIntegrationSchemaRequest<K, SchemaTypes[K]>;
139
- };
140
- export type UpsertIntegrationSchemaRequest = UpsertDataIntegrationSchemaRequest | UpsertGraphQLIntegrationSchemaRequest | UpsertApiIntegrationSchemaRequest;
141
- export type UpsertDataIntegrationSchemaRequest = UpsertIntegrationSchemaRequests[DatabaseIntegrationType];
142
- export type UpsertGraphQLIntegrationSchemaRequest = UpsertIntegrationSchemaRequests[IntegrationType.graphql];
143
- export type UpsertApiIntegrationSchemaRequest = UpsertIntegrationSchemaRequests[IntegrationType.api];
144
- export interface GetSchemaRequest {
145
- integrationId: IntegrationId;
146
- }
147
- export {};
@@ -1,2 +0,0 @@
1
- import { ApplicationSecrets } from './secret.types';
2
- export declare function convertToRunSecrets(appSecrets: ApplicationSecrets): RunSecrets;