@squidcloud/client 1.0.161 → 1.0.163

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/cjs/index.js CHANGED
@@ -28013,7 +28013,10 @@ __webpack_require__.r(__webpack_exports__);
28013
28013
  // EXPORTS
28014
28014
  __webpack_require__.d(__webpack_exports__, {
28015
28015
  AI_MODEL_NAMES: () => (/* reexport */ AI_MODEL_NAMES),
28016
+ AiChatbotChatContext: () => (/* reexport */ AiChatbotChatContext),
28017
+ AiChatbotMutationContext: () => (/* reexport */ AiChatbotMutationContext),
28016
28018
  AiChatbotProfileReference: () => (/* reexport */ AiChatbotProfileReference),
28019
+ ApiCallContext: () => (/* reexport */ ApiCallContext),
28017
28020
  ApiIntegrationTypes: () => (/* reexport */ ApiIntegrationTypes),
28018
28021
  AuthIntegrationTypes: () => (/* reexport */ AuthIntegrationTypes),
28019
28022
  BaseQueryBuilder: () => (/* reexport */ BaseQueryBuilder),
@@ -28023,15 +28026,18 @@ __webpack_require__.d(__webpack_exports__, {
28023
28026
  CronExpression: () => (/* reexport */ CronExpression),
28024
28027
  DEFAULT_SHORT_ID_LENGTH: () => (/* reexport */ DEFAULT_SHORT_ID_LENGTH),
28025
28028
  DatabaseIntegrationTypes: () => (/* reexport */ DatabaseIntegrationTypes),
28029
+ DistributedLockContext: () => (/* reexport */ DistributedLockContext),
28026
28030
  DocumentReference: () => (/* reexport */ DocumentReference),
28027
28031
  ENVIRONMENT_IDS: () => (/* reexport */ ENVIRONMENT_IDS),
28028
28032
  GraphQLClient: () => (/* reexport */ GraphQLClient),
28033
+ GraphqlContext: () => (/* reexport */ GraphqlContext),
28029
28034
  HttpStatus: () => (/* reexport */ http_status_enum_HttpStatus),
28030
28035
  IntegrationCategory: () => (/* reexport */ IntegrationCategory),
28031
28036
  IntegrationSchemaType: () => (/* reexport */ IntegrationSchemaType),
28032
28037
  IntegrationType: () => (/* reexport */ IntegrationType),
28033
28038
  JoinQueryBuilder: () => (/* reexport */ JoinQueryBuilder),
28034
- MutationPublicContext: () => (/* reexport */ MutationPublicContext),
28039
+ MutationContext: () => (/* reexport */ MutationContext),
28040
+ NativeQueryContext: () => (/* reexport */ NativeQueryContext),
28035
28041
  ObservabilityIntegrationTypes: () => (/* reexport */ ObservabilityIntegrationTypes),
28036
28042
  Pagination: () => (/* reexport */ Pagination),
28037
28043
  QueryBuilder: () => (/* reexport */ QueryBuilder),
@@ -28053,6 +28059,29 @@ __webpack_require__.d(__webpack_exports__, {
28053
28059
  newRelicRegionMap: () => (/* reexport */ newRelicRegionMap)
28054
28060
  });
28055
28061
 
28062
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/ai-chatbot.public-context.ts
28063
+ class AiChatbotChatContext {
28064
+ /**
28065
+ * @internal
28066
+ */
28067
+ constructor(prototype) {
28068
+ this.profileId = prototype.profileId;
28069
+ this.prompt = prototype.prompt;
28070
+ }
28071
+ }
28072
+ /** A context provided to the security rules of an AI Chatbot mutation. */
28073
+ class AiChatbotMutationContext {
28074
+ /**
28075
+ * @internal
28076
+ */
28077
+ constructor(prototype) {
28078
+ this.profileId = prototype.profileId;
28079
+ this.type = prototype.type;
28080
+ this.resource = prototype.resource;
28081
+ this.payload = prototype.payload;
28082
+ }
28083
+ }
28084
+
28056
28085
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/ai-chatbot.public-types.ts
28057
28086
  /** The supported AI model names. */
28058
28087
  const AI_MODEL_NAMES = [
@@ -28063,6 +28092,22 @@ const AI_MODEL_NAMES = [
28063
28092
  'gpt-4-1106-preview',
28064
28093
  ];
28065
28094
 
28095
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/api-call.public-context.ts
28096
+ /** The context of an API call. */
28097
+ class ApiCallContext {
28098
+ /** @internal */
28099
+ constructor(prototype) {
28100
+ this.endpointId = prototype.endpointId;
28101
+ this.url = prototype.url;
28102
+ this.method = prototype.method;
28103
+ this.headers = prototype.headers;
28104
+ this.body = prototype.body;
28105
+ this.queryParams = prototype.queryParams;
28106
+ this.pathParams = prototype.pathParams;
28107
+ this.serverUrlOverride = prototype.serverUrlOverride;
28108
+ }
28109
+ }
28110
+
28066
28111
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/application.public-types.ts
28067
28112
  // noinspection JSUnusedGlobalSymbols
28068
28113
  /** A set of predefined cron expressions. */
@@ -28266,6 +28311,29 @@ const ENVIRONMENT_IDS = ['dev', 'prod'];
28266
28311
  /** @deprecated. Use ENVIRONMENT_IDS. */
28267
28312
  const allEnvironmentIds = [...ENVIRONMENT_IDS];
28268
28313
 
28314
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/distributed-lock.public-context.ts
28315
+ /** The context provided to a secure distributed lock function. */
28316
+ class DistributedLockContext {
28317
+ /** @internal */
28318
+ constructor(mutex) {
28319
+ this.mutex = mutex;
28320
+ }
28321
+ }
28322
+
28323
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/graphql.public-context.ts
28324
+ /** The context provided to a secure GraphQL function. */
28325
+ class GraphqlContext {
28326
+ /**
28327
+ * @internal
28328
+ */
28329
+ constructor(prototype) {
28330
+ this.isGraphiQL = prototype.isGraphiQL;
28331
+ this.query = prototype.query;
28332
+ this.operationName = prototype.operationName;
28333
+ this.variables = prototype.variables;
28334
+ }
28335
+ }
28336
+
28269
28337
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/http-status.enum.ts
28270
28338
  var http_status_enum_HttpStatus;
28271
28339
  (function (HttpStatus) {
@@ -28442,13 +28510,13 @@ function isDataIntegrationType(type) {
28442
28510
  return DatabaseIntegrationTypes.includes(type);
28443
28511
  }
28444
28512
  function isDataIntegration(integration) {
28445
- return isDataIntegrationType(integration.type);
28513
+ return isDataIntegrationType(integration === null || integration === void 0 ? void 0 : integration.type);
28446
28514
  }
28447
28515
  function isAuthIntegrationType(type) {
28448
28516
  return AuthIntegrationTypes.includes(type);
28449
28517
  }
28450
28518
  function isAuthIntegration(integration) {
28451
- return isAuthIntegrationType(integration.type);
28519
+ return isAuthIntegrationType(integration === null || integration === void 0 ? void 0 : integration.type);
28452
28520
  }
28453
28521
 
28454
28522
  // EXTERNAL MODULE: ../node_modules/lodash/lodash.js
@@ -28457,7 +28525,7 @@ var lodash_default = /*#__PURE__*/__webpack_require__.n(lodash);
28457
28525
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/mutation.public-context.ts
28458
28526
 
28459
28527
  /** The mutation context that will be provided to the security function. */
28460
- class MutationPublicContext {
28528
+ class MutationContext {
28461
28529
  /**
28462
28530
  * @internal
28463
28531
  */
@@ -28483,6 +28551,17 @@ class MutationPublicContext {
28483
28551
  }
28484
28552
  }
28485
28553
 
28554
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/native-query.public-context.ts
28555
+ /** The context provided to the secure native query function. */
28556
+ class NativeQueryContext {
28557
+ /** @internal */
28558
+ constructor(query, params, clientId) {
28559
+ this.query = query;
28560
+ this.params = params;
28561
+ this.clientId = clientId;
28562
+ }
28563
+ }
28564
+
28486
28565
  // EXTERNAL MODULE: external "rxjs"
28487
28566
  var external_rxjs_ = __webpack_require__(1964);
28488
28567
  // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
@@ -29312,6 +29391,11 @@ var ClientConnectionState;
29312
29391
 
29313
29392
 
29314
29393
 
29394
+
29395
+
29396
+
29397
+
29398
+
29315
29399
 
29316
29400
 
29317
29401
 
@@ -30681,9 +30765,10 @@ function validateFieldSort(fieldSort) {
30681
30765
  if (!(fieldSort instanceof Object)) {
30682
30766
  throw new Error('Field sort has to be an object');
30683
30767
  }
30684
- (0,dist.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
30685
- (0,dist.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
30686
- validateFieldName(fieldSort.fieldName);
30768
+ const safeFieldSort = fieldSort;
30769
+ (0,dist.assertTruthy)(hasOnlyKeys(safeFieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
30770
+ (0,dist.assertTruthy)(isRightType(safeFieldSort.asc, 'boolean'), 'Asc needs to be boolean');
30771
+ validateFieldName(safeFieldSort.fieldName);
30687
30772
  }
30688
30773
  function validateOpenIdProvider(openIdProvider) {
30689
30774
  assertTruthy(openIdProvider, 'INVALID_PROVIDER');
@@ -30809,7 +30894,7 @@ function validateMutations(mutations) {
30809
30894
  }
30810
30895
  }
30811
30896
  function validateQueryLimit(limit) {
30812
- (0,dist.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
30897
+ (0,dist.assertNumber)(limit, 'Limit needs to be a number');
30813
30898
  if (limit === -1)
30814
30899
  return;
30815
30900
  (0,dist.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
@@ -30858,7 +30943,13 @@ function parseSquidDocId(squidDocId) {
30858
30943
  /** @internal */
30859
30944
  function getSquidDocId(...args) {
30860
30945
  const [a, b, c] = args;
30861
- const squidDocIdObjObj = typeof a === 'object' ? a : { docId: a, collectionName: b, integrationId: c };
30946
+ const squidDocIdObjObj = typeof a === 'object'
30947
+ ? a
30948
+ : {
30949
+ docId: a,
30950
+ collectionName: b,
30951
+ integrationId: c,
30952
+ };
30862
30953
  // Handle nulls and empty strings
30863
30954
  if (!squidDocIdObjObj.integrationId)
30864
30955
  squidDocIdObjObj.integrationId = undefined;
@@ -49112,9 +49203,12 @@ class DataManager {
49112
49203
  const failedDocsToResync = [...this.failedDocsToResync];
49113
49204
  this.failedDocsToResync.splice(0);
49114
49205
  for (const squidDocId of failedDocsToResync) {
49206
+ const { docId } = parseSquidDocId(squidDocId);
49115
49207
  this.setExpiration(squidDocId, true);
49116
49208
  try {
49117
- const results = await this.queryBuilderFactory.getForDocument(squidDocId).setForceFetchFromServer().snapshot();
49209
+ const results = docId.includes(SquidPlaceholderId)
49210
+ ? []
49211
+ : await this.queryBuilderFactory.getForDocument(squidDocId).setForceFetchFromServer().snapshot();
49118
49212
  (0,dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + squidDocId);
49119
49213
  /** The document does not exist anymore, so we can forget about it */
49120
49214
  if (!results.length) {
@@ -1,4 +1,4 @@
1
- import { AiChatbotMutationType, AiChatbotResourceType } from './ai-chatbot.types';
1
+ import { AiChatbotMutationType, AiChatbotResourceType } from './ai-chatbot.public-types';
2
2
  export declare class AiChatbotChatContext {
3
3
  readonly prompt: string;
4
4
  readonly profileId: string;
@@ -26,4 +26,6 @@ export interface AiChatbotChatOptions {
26
26
  includeReference?: boolean;
27
27
  responseFormat?: OpenAiResponseFormat;
28
28
  }
29
+ export type AiChatbotMutationType = 'insert' | 'update' | 'delete';
30
+ export type AiChatbotResourceType = 'instruction' | 'context' | 'profile';
29
31
  export {};
@@ -1,5 +1,6 @@
1
- import { ApiHeaders } from './api.types';
2
- import { ApiEndpointId, HttpMethod } from '../public-types/integrations/api.types';
1
+ import { ApiEndpointId, HttpMethod } from './integrations/api.types';
2
+ /** The headers of an API call. */
3
+ export type ApiHeaders = Record<string, string | number | boolean>;
3
4
  /** The context of an API call. */
4
5
  export declare class ApiCallContext {
5
6
  readonly endpointId: ApiEndpointId;
@@ -1,17 +1,17 @@
1
- import { MutationPublicContext } from './mutation.public-context';
2
- import { ApiCallContext } from '../types/api-call.context';
3
- import { GraphqlContext } from '../types/graphql.context';
4
- import { DistributedLockContext } from '../types/distributed-lock.context';
5
- import { NativeQueryContext } from '../types/native-query.context';
1
+ import { MutationContext } from './mutation.public-context';
2
+ import { ApiCallContext } from './api-call.public-context';
6
3
  import { QueryContext } from './query.public-context';
7
4
  import { AiChatbotActionType, DatabaseActionType, TopicActionType } from './bundle-data.public-types';
8
- import { AiChatbotChatContext, AiChatbotMutationContext } from '../types/ai-chatbot.context';
9
5
  import { ClientConnectionState } from './socket.public-types';
10
6
  import { DocumentData } from './document.public-types';
11
7
  import { MutationType } from './mutation.public-types';
12
8
  import { ClientId, SquidDocId } from './communication.public-types';
13
9
  import { TopicReadContext, TopicWriteContext } from './topic.public-context';
14
- export type SecureDatabaseAction<T extends DatabaseActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: QueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: MutationPublicContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
10
+ import { NativeQueryContext } from './native-query.public-context';
11
+ import { DistributedLockContext } from './distributed-lock.public-context';
12
+ import { GraphqlContext } from './graphql.public-context';
13
+ import { AiChatbotChatContext, AiChatbotMutationContext } from './ai-chatbot.public-context';
14
+ export type SecureDatabaseAction<T extends DatabaseActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: QueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: MutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
15
15
  export type SecureTopicAction<T extends TopicActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: TopicReadContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: TopicWriteContext<T>) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
16
16
  export type SecureApiAction = ((context: ApiCallContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
17
17
  export type SecureNativeQueryAction = ((context: NativeQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
@@ -64,9 +64,9 @@ export type ObservabilityIntegrationConfig = IntegrationConfigTypes[Observabilit
64
64
  export type AuthIntegrationType = (typeof AuthIntegrationTypes)[number];
65
65
  export type AuthIntegrationConfig = IntegrationConfigTypes[AuthIntegrationType];
66
66
  export declare function isDataIntegrationType(type: unknown): type is DatabaseIntegrationType;
67
- export declare function isDataIntegration(integration: any): integration is BaseDatabaseIntegrationConfig;
68
- export declare function isAuthIntegrationType(type: IntegrationType): type is AuthIntegrationType;
69
- export declare function isAuthIntegration(integration: any): integration is AuthIntegrationConfig;
67
+ export declare function isDataIntegration(integration: unknown): integration is BaseDatabaseIntegrationConfig;
68
+ export declare function isAuthIntegrationType(type: unknown): type is AuthIntegrationType;
69
+ export declare function isAuthIntegration(integration: unknown): integration is AuthIntegrationConfig;
70
70
  export interface BaseIntegrationConfig {
71
71
  id: IntegrationId;
72
72
  type: IntegrationTypeWithConfig;
@@ -2,7 +2,7 @@ import { Paths } from './typescript.public-types';
2
2
  import { BeforeAndAfterDocs } from './document.public-types';
3
3
  import { Mutation, MutationType } from './mutation.public-types';
4
4
  /** The mutation context that will be provided to the security function. */
5
- export declare class MutationPublicContext<T = any> {
5
+ export declare class MutationContext<T = any> {
6
6
  readonly mutation: Mutation<T>;
7
7
  readonly beforeAndAfterDocs: BeforeAndAfterDocs<T>;
8
8
  readonly serverTimeStamp: Date;
@@ -1,4 +1,4 @@
1
- import { ClientId } from '../public-types/communication.public-types';
1
+ import { ClientId } from './communication.public-types';
2
2
  /** The context provided to the secure native query function. */
3
3
  export declare class NativeQueryContext {
4
4
  readonly query: string;
@@ -1,4 +1,2 @@
1
- /** The headers of an API call. */
2
- export type ApiHeaders = Record<string, string | number | boolean>;
3
1
  /** The query parameters of an API call. */
4
2
  export type ApiQueryParams = Record<string, string | number | boolean>;
@@ -1,5 +1,5 @@
1
- export declare function getInPath(obj: any, path: string, delimiter?: string): any;
2
- export declare function setInPath(obj: any, path: string, value: any, delimiter?: string): void;
3
- export declare function deleteInPath(obj: any, path: string, delimiter?: string): void;
1
+ export declare function getInPath(obj: Readonly<Record<string, unknown>>, path: string, delimiter?: string): any;
2
+ export declare function setInPath(obj: object, path: string, value: unknown, delimiter?: string): void;
3
+ export declare function deleteInPath(obj: object, path: string, delimiter?: string): void;
4
4
  export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
5
5
  export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
@@ -1,5 +1,5 @@
1
- export declare function normalizeJsonAsString(json: any): string;
1
+ export declare function normalizeJsonAsString(json: unknown): string;
2
2
  export declare function serializeObj(obj: unknown): string;
3
3
  export declare function deserializeObj<T = any>(str: string): T;
4
- export declare function encodeValueForMapping(value: any): string;
4
+ export declare function encodeValueForMapping(value: unknown): string;
5
5
  export declare function decodeValueForMapping(encodedString: string): any;
@@ -8,11 +8,11 @@ export declare class ValidationError extends Error {
8
8
  }
9
9
  export declare function isValidId(id: unknown): boolean;
10
10
  export declare function validateId(id: unknown, message: string): void;
11
- export declare function validateFieldSort(fieldSort: any): void;
11
+ export declare function validateFieldSort(fieldSort: unknown): void;
12
12
  export declare function validateOpenIdProvider(openIdProvider: OpenIdProvider | undefined): OpenIdProvider;
13
- export declare function validateOpenIdProviderType(providerType: any): void;
14
- export declare function validateMutations(mutations: any): void;
15
- export declare function validateQueryLimit(limit: any): void;
13
+ export declare function validateOpenIdProviderType(providerType: unknown): void;
14
+ export declare function validateMutations(mutations: unknown): void;
15
+ export declare function validateQueryLimit(limit: unknown): void;
16
16
  /** Returns true if the value is not an empty string (undefined/null are considered empty). */
17
17
  export declare function isNotEmpty(value: string | undefined | null): value is string;
18
18
  /**
@@ -1,12 +1,16 @@
1
1
  export * from '../../internal-common/src/public-types/ai-assistant.public-types';
2
+ export * from '../../internal-common/src/public-types/ai-chatbot.public-context';
2
3
  export * from '../../internal-common/src/public-types/ai-chatbot.public-types';
4
+ export * from '../../internal-common/src/public-types/api-call.public-context';
3
5
  export * from '../../internal-common/src/public-types/application.public-types';
4
6
  export * from '../../internal-common/src/public-types/base-query-builder.public-types';
5
7
  export * from '../../internal-common/src/public-types/bundle-api.public-types';
6
8
  export * from '../../internal-common/src/public-types/bundle-data.public-types';
7
9
  export * from '../../internal-common/src/public-types/communication.public-types';
8
10
  export * from '../../internal-common/src/public-types/context.public-types';
11
+ export * from '../../internal-common/src/public-types/distributed-lock.public-context';
9
12
  export * from '../../internal-common/src/public-types/document.public-types';
13
+ export * from '../../internal-common/src/public-types/graphql.public-context';
10
14
  export * from '../../internal-common/src/public-types/graphql.public-types';
11
15
  export * from '../../internal-common/src/public-types/http-status.enum';
12
16
  export * from '../../internal-common/src/public-types/integration.public-types';
@@ -19,6 +23,7 @@ export * from '../../internal-common/src/public-types/integrations/queue-types';
19
23
  export * from '../../internal-common/src/public-types/integrations/schemas';
20
24
  export * from '../../internal-common/src/public-types/mutation.public-context';
21
25
  export * from '../../internal-common/src/public-types/mutation.public-types';
26
+ export * from '../../internal-common/src/public-types/native-query.public-context';
22
27
  export * from '../../internal-common/src/public-types/native-query.public-types';
23
28
  export * from '../../internal-common/src/public-types/pagination.public-types';
24
29
  export * from '../../internal-common/src/public-types/query.public-context';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.161",
3
+ "version": "1.0.163",
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",