@wix/auto_sdk_duplexer_publisher 1.0.10 → 1.0.12
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/build/cjs/index.js.map +1 -1
- package/build/cjs/index.typings.d.ts +1 -0
- package/build/cjs/index.typings.js.map +1 -1
- package/build/cjs/schemas.d.ts +19 -0
- package/build/cjs/schemas.js +69 -0
- package/build/cjs/schemas.js.map +1 -0
- package/build/es/index.mjs.map +1 -1
- package/build/es/index.typings.d.mts +1 -0
- package/build/es/index.typings.mjs.map +1 -1
- package/build/es/schemas.d.mts +19 -0
- package/build/es/schemas.mjs +31 -0
- package/build/es/schemas.mjs.map +1 -0
- package/build/internal/cjs/index.js.map +1 -1
- package/build/internal/cjs/index.typings.d.ts +1 -0
- package/build/internal/cjs/index.typings.js.map +1 -1
- package/build/internal/cjs/schemas.d.ts +19 -0
- package/build/internal/cjs/schemas.js +69 -0
- package/build/internal/cjs/schemas.js.map +1 -0
- package/build/internal/es/index.mjs.map +1 -1
- package/build/internal/es/index.typings.d.mts +1 -0
- package/build/internal/es/index.typings.mjs.map +1 -1
- package/build/internal/es/schemas.d.mts +19 -0
- package/build/internal/es/schemas.mjs +31 -0
- package/build/internal/es/schemas.mjs.map +1 -0
- package/package.json +12 -5
- package/schemas/package.json +3 -0
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts","../../src/realtime-v4-message-publisher.public.ts","../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.context.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts","../../src/realtime-v4-message-publisher.public.ts","../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.context.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBC,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AExHO,SAASC,SAAQ,YAA0C;AAChE,SAAO,CACL,SACA,YAEAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnBA,IAAAC,uBAAiC;AAG1B,IAAMC,WAEK,2DAAiBA,QAAa;","names":["publish","publish","sdkTransformError","publish","import_rest_modules","publish"]}
|
|
@@ -74,6 +74,7 @@ interface PublishToUserResponse {
|
|
|
74
74
|
* @requiredField message.payload
|
|
75
75
|
* @requiredField options.channels
|
|
76
76
|
* @permissionId realtime:v4:message:publish
|
|
77
|
+
* @applicableIdentity APP
|
|
77
78
|
* @fqn com.wix.realtime.v4.DuplexerApiV4.Publish
|
|
78
79
|
*/
|
|
79
80
|
declare function publish(message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.typings.ts","../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.universal.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../index.typings.ts","../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.universal.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBC,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;","names":["publish","publish","sdkTransformError"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const PublishRequest: z.ZodObject<{
|
|
4
|
+
message: z.ZodObject<{
|
|
5
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
eventName: z.ZodString;
|
|
7
|
+
payload: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
8
|
+
publisherInfo: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
options: z.ZodObject<{
|
|
13
|
+
channels: z.ZodArray<z.ZodString>;
|
|
14
|
+
resourceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const PublishResponse: z.ZodObject<{}, z.core.$strip>;
|
|
18
|
+
|
|
19
|
+
export { PublishRequest, PublishResponse };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// schemas.ts
|
|
31
|
+
var schemas_exports = {};
|
|
32
|
+
__export(schemas_exports, {
|
|
33
|
+
PublishRequest: () => PublishRequest,
|
|
34
|
+
PublishResponse: () => PublishResponse
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(schemas_exports);
|
|
37
|
+
|
|
38
|
+
// src/realtime-v4-message-publisher.schemas.ts
|
|
39
|
+
var z = __toESM(require("zod"));
|
|
40
|
+
var PublishRequest = z.object({
|
|
41
|
+
message: z.object({
|
|
42
|
+
_id: z.string().describe("Unique message identifier").regex(
|
|
43
|
+
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
44
|
+
"Must be a valid GUID"
|
|
45
|
+
).optional(),
|
|
46
|
+
eventName: z.string().describe('Event name, e.g "product_added"').max(1e3),
|
|
47
|
+
payload: z.record(z.string(), z.any()).describe(
|
|
48
|
+
'Event payload, e.g { "product_id": "123", "product_name": "Product 1" }'
|
|
49
|
+
),
|
|
50
|
+
publisherInfo: z.object({
|
|
51
|
+
uid: z.string().describe(
|
|
52
|
+
"Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher."
|
|
53
|
+
).max(1e3).optional()
|
|
54
|
+
}).describe("Info regarding the publisher of the message").optional()
|
|
55
|
+
}),
|
|
56
|
+
options: z.object({
|
|
57
|
+
channels: z.array(z.string()).max(10),
|
|
58
|
+
resourceId: z.string().describe(
|
|
59
|
+
'Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message.'
|
|
60
|
+
).max(1e3).optional().nullable()
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
var PublishResponse = z.object({});
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
PublishRequest,
|
|
67
|
+
PublishResponse
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../schemas.ts","../../src/realtime-v4-message-publisher.schemas.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.schemas.js';\n","import * as z from 'zod';\n\nexport const PublishRequest = z.object({\n message: z.object({\n _id: z\n .string()\n .describe('Unique message identifier')\n .regex(\n /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,\n 'Must be a valid GUID'\n )\n .optional(),\n eventName: z.string().describe('Event name, e.g \"product_added\"').max(1000),\n payload: z\n .record(z.string(), z.any())\n .describe(\n 'Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" }'\n ),\n publisherInfo: z\n .object({\n uid: z\n .string()\n .describe(\n 'Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.'\n )\n .max(1000)\n .optional(),\n })\n .describe('Info regarding the publisher of the message')\n .optional(),\n }),\n options: z.object({\n channels: z.array(z.string()).max(10),\n resourceId: z\n .string()\n .describe(\n 'Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.'\n )\n .max(1000)\n .optional()\n .nullable(),\n }),\n});\nexport const PublishResponse = z.object({});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,QAAmB;AAEZ,IAAM,iBAAmB,SAAO;AAAA,EACrC,SAAW,SAAO;AAAA,IAChB,KACG,SAAO,EACP,SAAS,2BAA2B,EACpC;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC,SAAS;AAAA,IACZ,WAAa,SAAO,EAAE,SAAS,iCAAiC,EAAE,IAAI,GAAI;AAAA,IAC1E,SACG,SAAS,SAAO,GAAK,MAAI,CAAC,EAC1B;AAAA,MACC;AAAA,IACF;AAAA,IACF,eACG,SAAO;AAAA,MACN,KACG,SAAO,EACP;AAAA,QACC;AAAA,MACF,EACC,IAAI,GAAI,EACR,SAAS;AAAA,IACd,CAAC,EACA,SAAS,6CAA6C,EACtD,SAAS;AAAA,EACd,CAAC;AAAA,EACD,SAAW,SAAO;AAAA,IAChB,UAAY,QAAQ,SAAO,CAAC,EAAE,IAAI,EAAE;AAAA,IACpC,YACG,SAAO,EACP;AAAA,MACC;AAAA,IACF,EACC,IAAI,GAAI,EACR,SAAS,EACT,SAAS;AAAA,EACd,CAAC;AACH,CAAC;AACM,IAAM,kBAAoB,SAAO,CAAC,CAAC;","names":[]}
|
package/build/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts","../../src/realtime-v4-message-publisher.public.ts","../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts","../../src/realtime-v4-message-publisher.public.ts","../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBA,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,UAAU,sCAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,mBAAmB;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AExHO,SAASC,SAAQ,YAA0C;AAChE,SAAO,CACL,SACA,YAEAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnBA,SAAS,wBAAwB;AAG1B,IAAMC,WAEK,iCAAiBA,QAAa;","names":["publish","publish","publish"]}
|
|
@@ -74,6 +74,7 @@ interface PublishToUserResponse {
|
|
|
74
74
|
* @requiredField message.payload
|
|
75
75
|
* @requiredField options.channels
|
|
76
76
|
* @permissionId realtime:v4:message:publish
|
|
77
|
+
* @applicableIdentity APP
|
|
77
78
|
* @fqn com.wix.realtime.v4.DuplexerApiV4.Publish
|
|
78
79
|
*/
|
|
79
80
|
declare function publish(message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../src/realtime-v4-message-publisher.universal.ts","../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBA,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,UAAU,sCAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,mBAAmB;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;","names":["publish"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const PublishRequest: z.ZodObject<{
|
|
4
|
+
message: z.ZodObject<{
|
|
5
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
eventName: z.ZodString;
|
|
7
|
+
payload: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
8
|
+
publisherInfo: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
options: z.ZodObject<{
|
|
13
|
+
channels: z.ZodArray<z.ZodString>;
|
|
14
|
+
resourceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const PublishResponse: z.ZodObject<{}, z.core.$strip>;
|
|
18
|
+
|
|
19
|
+
export { PublishRequest, PublishResponse };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/realtime-v4-message-publisher.schemas.ts
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
var PublishRequest = z.object({
|
|
4
|
+
message: z.object({
|
|
5
|
+
_id: z.string().describe("Unique message identifier").regex(
|
|
6
|
+
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
7
|
+
"Must be a valid GUID"
|
|
8
|
+
).optional(),
|
|
9
|
+
eventName: z.string().describe('Event name, e.g "product_added"').max(1e3),
|
|
10
|
+
payload: z.record(z.string(), z.any()).describe(
|
|
11
|
+
'Event payload, e.g { "product_id": "123", "product_name": "Product 1" }'
|
|
12
|
+
),
|
|
13
|
+
publisherInfo: z.object({
|
|
14
|
+
uid: z.string().describe(
|
|
15
|
+
"Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher."
|
|
16
|
+
).max(1e3).optional()
|
|
17
|
+
}).describe("Info regarding the publisher of the message").optional()
|
|
18
|
+
}),
|
|
19
|
+
options: z.object({
|
|
20
|
+
channels: z.array(z.string()).max(10),
|
|
21
|
+
resourceId: z.string().describe(
|
|
22
|
+
'Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message.'
|
|
23
|
+
).max(1e3).optional().nullable()
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
var PublishResponse = z.object({});
|
|
27
|
+
export {
|
|
28
|
+
PublishRequest,
|
|
29
|
+
PublishResponse
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=schemas.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/realtime-v4-message-publisher.schemas.ts"],"sourcesContent":["import * as z from 'zod';\n\nexport const PublishRequest = z.object({\n message: z.object({\n _id: z\n .string()\n .describe('Unique message identifier')\n .regex(\n /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,\n 'Must be a valid GUID'\n )\n .optional(),\n eventName: z.string().describe('Event name, e.g \"product_added\"').max(1000),\n payload: z\n .record(z.string(), z.any())\n .describe(\n 'Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" }'\n ),\n publisherInfo: z\n .object({\n uid: z\n .string()\n .describe(\n 'Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.'\n )\n .max(1000)\n .optional(),\n })\n .describe('Info regarding the publisher of the message')\n .optional(),\n }),\n options: z.object({\n channels: z.array(z.string()).max(10),\n resourceId: z\n .string()\n .describe(\n 'Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.'\n )\n .max(1000)\n .optional()\n .nullable(),\n }),\n});\nexport const PublishResponse = z.object({});\n"],"mappings":";AAAA,YAAY,OAAO;AAEZ,IAAM,iBAAmB,SAAO;AAAA,EACrC,SAAW,SAAO;AAAA,IAChB,KACG,SAAO,EACP,SAAS,2BAA2B,EACpC;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC,SAAS;AAAA,IACZ,WAAa,SAAO,EAAE,SAAS,iCAAiC,EAAE,IAAI,GAAI;AAAA,IAC1E,SACG,SAAS,SAAO,GAAK,MAAI,CAAC,EAC1B;AAAA,MACC;AAAA,IACF;AAAA,IACF,eACG,SAAO;AAAA,MACN,KACG,SAAO,EACP;AAAA,QACC;AAAA,MACF,EACC,IAAI,GAAI,EACR,SAAS;AAAA,IACd,CAAC,EACA,SAAS,6CAA6C,EACtD,SAAS;AAAA,EACd,CAAC;AAAA,EACD,SAAW,SAAO;AAAA,IAChB,UAAY,QAAQ,SAAO,CAAC,EAAE,IAAI,EAAE;AAAA,IACpC,YACG,SAAO,EACP;AAAA,MACC;AAAA,IACF,EACC,IAAI,GAAI,EACR,SAAS,EACT,SAAS;AAAA,EACd,CAAC;AACH,CAAC;AACM,IAAM,kBAAoB,SAAO,CAAC,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../index.ts","../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts","../../../src/realtime-v4-message-publisher.public.ts","../../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.context.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../../index.ts","../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts","../../../src/realtime-v4-message-publisher.public.ts","../../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.context.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBC,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AExHO,SAASC,SAAQ,YAA0C;AAChE,SAAO,CACL,SACA,YAEAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnBA,IAAAC,uBAAiC;AAG1B,IAAMC,WAEK,2DAAiBA,QAAa;","names":["publish","publish","sdkTransformError","publish","import_rest_modules","publish"]}
|
|
@@ -74,6 +74,7 @@ interface PublishToUserResponse {
|
|
|
74
74
|
* @requiredField message.payload
|
|
75
75
|
* @requiredField options.channels
|
|
76
76
|
* @permissionId realtime:v4:message:publish
|
|
77
|
+
* @applicableIdentity APP
|
|
77
78
|
* @fqn com.wix.realtime.v4.DuplexerApiV4.Publish
|
|
78
79
|
*/
|
|
79
80
|
declare function publish(message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../index.typings.ts","../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.universal.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../../index.typings.ts","../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.universal.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAAsD;;;ACDtD,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBC,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;","names":["publish","publish","sdkTransformError"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const PublishRequest: z.ZodObject<{
|
|
4
|
+
message: z.ZodObject<{
|
|
5
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
eventName: z.ZodString;
|
|
7
|
+
payload: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
8
|
+
publisherInfo: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
options: z.ZodObject<{
|
|
13
|
+
channels: z.ZodArray<z.ZodString>;
|
|
14
|
+
resourceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const PublishResponse: z.ZodObject<{}, z.core.$strip>;
|
|
18
|
+
|
|
19
|
+
export { PublishRequest, PublishResponse };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// schemas.ts
|
|
31
|
+
var schemas_exports = {};
|
|
32
|
+
__export(schemas_exports, {
|
|
33
|
+
PublishRequest: () => PublishRequest,
|
|
34
|
+
PublishResponse: () => PublishResponse
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(schemas_exports);
|
|
37
|
+
|
|
38
|
+
// src/realtime-v4-message-publisher.schemas.ts
|
|
39
|
+
var z = __toESM(require("zod"));
|
|
40
|
+
var PublishRequest = z.object({
|
|
41
|
+
message: z.object({
|
|
42
|
+
_id: z.string().describe("Unique message identifier").regex(
|
|
43
|
+
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
44
|
+
"Must be a valid GUID"
|
|
45
|
+
).optional(),
|
|
46
|
+
eventName: z.string().describe('Event name, e.g "product_added"').max(1e3),
|
|
47
|
+
payload: z.record(z.string(), z.any()).describe(
|
|
48
|
+
'Event payload, e.g { "product_id": "123", "product_name": "Product 1" }'
|
|
49
|
+
),
|
|
50
|
+
publisherInfo: z.object({
|
|
51
|
+
uid: z.string().describe(
|
|
52
|
+
"Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher."
|
|
53
|
+
).max(1e3).optional()
|
|
54
|
+
}).describe("Info regarding the publisher of the message").optional()
|
|
55
|
+
}),
|
|
56
|
+
options: z.object({
|
|
57
|
+
channels: z.array(z.string()).max(10),
|
|
58
|
+
resourceId: z.string().describe(
|
|
59
|
+
'Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message.'
|
|
60
|
+
).max(1e3).optional().nullable()
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
var PublishResponse = z.object({});
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
PublishRequest,
|
|
67
|
+
PublishResponse
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../schemas.ts","../../../src/realtime-v4-message-publisher.schemas.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.schemas.js';\n","import * as z from 'zod';\n\nexport const PublishRequest = z.object({\n message: z.object({\n _id: z\n .string()\n .describe('Unique message identifier')\n .regex(\n /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,\n 'Must be a valid GUID'\n )\n .optional(),\n eventName: z.string().describe('Event name, e.g \"product_added\"').max(1000),\n payload: z\n .record(z.string(), z.any())\n .describe(\n 'Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" }'\n ),\n publisherInfo: z\n .object({\n uid: z\n .string()\n .describe(\n 'Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.'\n )\n .max(1000)\n .optional(),\n })\n .describe('Info regarding the publisher of the message')\n .optional(),\n }),\n options: z.object({\n channels: z.array(z.string()).max(10),\n resourceId: z\n .string()\n .describe(\n 'Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.'\n )\n .max(1000)\n .optional()\n .nullable(),\n }),\n});\nexport const PublishResponse = z.object({});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,QAAmB;AAEZ,IAAM,iBAAmB,SAAO;AAAA,EACrC,SAAW,SAAO;AAAA,IAChB,KACG,SAAO,EACP,SAAS,2BAA2B,EACpC;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC,SAAS;AAAA,IACZ,WAAa,SAAO,EAAE,SAAS,iCAAiC,EAAE,IAAI,GAAI;AAAA,IAC1E,SACG,SAAS,SAAO,GAAK,MAAI,CAAC,EAC1B;AAAA,MACC;AAAA,IACF;AAAA,IACF,eACG,SAAO;AAAA,MACN,KACG,SAAO,EACP;AAAA,QACC;AAAA,MACF,EACC,IAAI,GAAI,EACR,SAAS;AAAA,IACd,CAAC,EACA,SAAS,6CAA6C,EACtD,SAAS;AAAA,EACd,CAAC;AAAA,EACD,SAAW,SAAO;AAAA,IAChB,UAAY,QAAQ,SAAO,CAAC,EAAE,IAAI,EAAE;AAAA,IACpC,YACG,SAAO,EACP;AAAA,MACC;AAAA,IACF,EACC,IAAI,GAAI,EACR,SAAS,EACT,SAAS;AAAA,EACd,CAAC;AACH,CAAC;AACM,IAAM,kBAAoB,SAAO,CAAC,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts","../../../src/realtime-v4-message-publisher.public.ts","../../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts","../../../src/realtime-v4-message-publisher.public.ts","../../../src/realtime-v4-message-publisher.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Message,\n PublishOptions,\n publish as universalPublish,\n} from './realtime-v4-message-publisher.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/duplexer' };\n\nexport function publish(httpClient: HttpClient): PublishSignature {\n return (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ) =>\n universalPublish(\n message,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface PublishSignature {\n /** */\n (\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n ): Promise<void>;\n}\n\nexport {\n Message,\n PublishOptions,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n PublishToUserResponse,\n PublisherInfo,\n UserIdList,\n} from './realtime-v4-message-publisher.universal.js';\n","import { publish as publicPublish } from './realtime-v4-message-publisher.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const publish: MaybeContext<\n BuildRESTFunction<typeof publicPublish> & typeof publicPublish\n> = /*#__PURE__*/ createRESTModule(publicPublish);\n\nexport {\n Message,\n PublisherInfo,\n PublishRequest,\n PublishResponse,\n PublishToUserRequest,\n PublishToUserRequestTargetingOneOf,\n UserIdList,\n PublishToUserResponse,\n PublishOptions,\n} from './realtime-v4-message-publisher.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBA,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,UAAU,sCAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,mBAAmB;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AExHO,SAASC,SAAQ,YAA0C;AAChE,SAAO,CACL,SACA,YAEAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnBA,SAAS,wBAAwB;AAG1B,IAAMC,WAEK,iCAAiBA,QAAa;","names":["publish","publish","publish"]}
|
|
@@ -74,6 +74,7 @@ interface PublishToUserResponse {
|
|
|
74
74
|
* @requiredField message.payload
|
|
75
75
|
* @requiredField options.channels
|
|
76
76
|
* @permissionId realtime:v4:message:publish
|
|
77
|
+
* @applicableIdentity APP
|
|
77
78
|
* @fqn com.wix.realtime.v4.DuplexerApiV4.Publish
|
|
78
79
|
*/
|
|
79
80
|
declare function publish(message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/realtime-v4-message-publisher.universal.ts","../../../src/realtime-v4-message-publisher.http.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport { renameKeysFromSDKRequestToRESTRequest } from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\n\nexport interface Message {\n /**\n * Unique message identifier\n * @readonly\n * @format GUID\n */\n _id?: string;\n /**\n * Event name, e.g \"product_added\"\n * @maxLength 1000\n */\n eventName?: string;\n /** Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" } */\n payload?: Record<string, any> | null;\n /** Info regarding the publisher of the message */\n publisherInfo?: PublisherInfo;\n}\n\nexport interface PublisherInfo {\n /**\n * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.\n * @maxLength 1000\n */\n uid?: string;\n}\n\nexport interface PublishRequest {\n message: Message;\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\nexport interface PublishResponse {}\n\nexport interface PublishToUserRequest\n extends PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n message?: Message;\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n\n/** @oneof */\nexport interface PublishToUserRequestTargetingOneOf {\n /** list of user ids to receive the message */\n includeRecipients?: UserIdList;\n /** list of user ids to exclude from receiving the message */\n excludeRecipients?: UserIdList;\n}\n\nexport interface UserIdList {\n /**\n * @maxSize 1000\n * @maxLength 1000\n */\n userId?: string[];\n}\n\nexport interface PublishToUserResponse {}\n\n/** @public\n * @requiredField message\n * @requiredField message.eventName\n * @requiredField message.payload\n * @requiredField options.channels\n * @permissionId realtime:v4:message:publish\n * @applicableIdentity APP\n * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish\n */\nexport async function publish(\n message: NonNullablePaths<Message, `eventName` | `payload`, 2>,\n options?: NonNullablePaths<PublishOptions, `channels`, 2>\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n message: message,\n channels: options?.channels,\n resourceId: options?.resourceId,\n });\n\n const reqOpts = ambassadorWixRealtimeV4Message.publish(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n message: '$[0]',\n channels: '$[1].channels',\n resourceId: '$[1].resourceId',\n },\n singleArgumentUnchanged: false,\n },\n ['message', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface PublishOptions {\n /**\n * Channel names to publish to, e.g [\"product_notifications\", \"site_notifications\"]\n * @maxSize 10\n * @maxLength 140\n */\n channels: string[];\n /**\n * Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.\n * @maxLength 1000\n */\n resourceId?: string | null;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveComWixRealtimeV4DuplexerApiV4Url(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'api._api_base_domain_': [\n {\n srcPath: '/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/wix-duplexer-api',\n destPath: '',\n },\n ],\n 'www.wixapis.com': [\n {\n srcPath: '/realtime/v4/publish',\n destPath: '/v4/publish',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_duplexer_publisher';\n\nexport function publish(payload: object): RequestOptionsFactory<any> {\n function __publish({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.realtime.v4.message',\n method: 'POST' as any,\n methodFqn: 'com.wix.realtime.v4.DuplexerApiV4.Publish',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveComWixRealtimeV4DuplexerApiV4Url({\n protoPath: '/v4/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,6CAA6C;;;ACDtD,SAAS,kBAAkB;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB;AAAA,MACvB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAEd,SAAS,QAAQ,SAA6C;AACnE,WAAS,UAAU,EAAE,KAAK,GAAQ;AAChC,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,wCAAwC;AAAA,QAC3C,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD4BA,eAAsBA,SACpB,SACA,SACe;AAEf,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,UAAU,sCAAsC;AAAA,IACpD;AAAA,IACA,UAAU,SAAS;AAAA,IACnB,YAAY,SAAS;AAAA,EACvB,CAAC;AAED,QAAM,UAAyC,QAAQ,OAAO;AAE9D,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAAA,EACjC,SAAS,KAAU;AACjB,UAAM,mBAAmB;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,QACd;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,WAAW,SAAS;AAAA,IACvB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;","names":["publish"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const PublishRequest: z.ZodObject<{
|
|
4
|
+
message: z.ZodObject<{
|
|
5
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
eventName: z.ZodString;
|
|
7
|
+
payload: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
8
|
+
publisherInfo: z.ZodOptional<z.ZodObject<{
|
|
9
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
options: z.ZodObject<{
|
|
13
|
+
channels: z.ZodArray<z.ZodString>;
|
|
14
|
+
resourceId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const PublishResponse: z.ZodObject<{}, z.core.$strip>;
|
|
18
|
+
|
|
19
|
+
export { PublishRequest, PublishResponse };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/realtime-v4-message-publisher.schemas.ts
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
var PublishRequest = z.object({
|
|
4
|
+
message: z.object({
|
|
5
|
+
_id: z.string().describe("Unique message identifier").regex(
|
|
6
|
+
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,
|
|
7
|
+
"Must be a valid GUID"
|
|
8
|
+
).optional(),
|
|
9
|
+
eventName: z.string().describe('Event name, e.g "product_added"').max(1e3),
|
|
10
|
+
payload: z.record(z.string(), z.any()).describe(
|
|
11
|
+
'Event payload, e.g { "product_id": "123", "product_name": "Product 1" }'
|
|
12
|
+
),
|
|
13
|
+
publisherInfo: z.object({
|
|
14
|
+
uid: z.string().describe(
|
|
15
|
+
"Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher."
|
|
16
|
+
).max(1e3).optional()
|
|
17
|
+
}).describe("Info regarding the publisher of the message").optional()
|
|
18
|
+
}),
|
|
19
|
+
options: z.object({
|
|
20
|
+
channels: z.array(z.string()).max(10),
|
|
21
|
+
resourceId: z.string().describe(
|
|
22
|
+
'Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message.'
|
|
23
|
+
).max(1e3).optional().nullable()
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
var PublishResponse = z.object({});
|
|
27
|
+
export {
|
|
28
|
+
PublishRequest,
|
|
29
|
+
PublishResponse
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=schemas.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/realtime-v4-message-publisher.schemas.ts"],"sourcesContent":["import * as z from 'zod';\n\nexport const PublishRequest = z.object({\n message: z.object({\n _id: z\n .string()\n .describe('Unique message identifier')\n .regex(\n /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,\n 'Must be a valid GUID'\n )\n .optional(),\n eventName: z.string().describe('Event name, e.g \"product_added\"').max(1000),\n payload: z\n .record(z.string(), z.any())\n .describe(\n 'Event payload, e.g { \"product_id\": \"123\", \"product_name\": \"Product 1\" }'\n ),\n publisherInfo: z\n .object({\n uid: z\n .string()\n .describe(\n 'Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher.'\n )\n .max(1000)\n .optional(),\n })\n .describe('Info regarding the publisher of the message')\n .optional(),\n }),\n options: z.object({\n channels: z.array(z.string()).max(10),\n resourceId: z\n .string()\n .describe(\n 'Optional sub resource identifier, e.g \"important_notification\", only subscribers to this specific resource will receive the message.'\n )\n .max(1000)\n .optional()\n .nullable(),\n }),\n});\nexport const PublishResponse = z.object({});\n"],"mappings":";AAAA,YAAY,OAAO;AAEZ,IAAM,iBAAmB,SAAO;AAAA,EACrC,SAAW,SAAO;AAAA,IAChB,KACG,SAAO,EACP,SAAS,2BAA2B,EACpC;AAAA,MACC;AAAA,MACA;AAAA,IACF,EACC,SAAS;AAAA,IACZ,WAAa,SAAO,EAAE,SAAS,iCAAiC,EAAE,IAAI,GAAI;AAAA,IAC1E,SACG,SAAS,SAAO,GAAK,MAAI,CAAC,EAC1B;AAAA,MACC;AAAA,IACF;AAAA,IACF,eACG,SAAO;AAAA,MACN,KACG,SAAO,EACP;AAAA,QACC;AAAA,MACF,EACC,IAAI,GAAI,EACR,SAAS;AAAA,IACd,CAAC,EACA,SAAS,6CAA6C,EACtD,SAAS;AAAA,EACd,CAAC;AAAA,EACD,SAAW,SAAO;AAAA,IAChB,UAAY,QAAQ,SAAO,CAAC,EAAE,IAAI,EAAE;AAAA,IACpC,YACG,SAAO,EACP;AAAA,MACC;AAAA,IACF,EACC,IAAI,GAAI,EACR,SAAS,EACT,SAAS;AAAA,EACd,CAAC;AACH,CAAC;AACM,IAAM,kBAAoB,SAAO,CAAC,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/auto_sdk_duplexer_publisher",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -21,16 +21,23 @@
|
|
|
21
21
|
"import": "./build/es/meta.mjs",
|
|
22
22
|
"require": "./build/cjs/meta.js",
|
|
23
23
|
"types": "./build/es/meta.d.mts"
|
|
24
|
+
},
|
|
25
|
+
"./schemas": {
|
|
26
|
+
"import": "./build/es/schemas.mjs",
|
|
27
|
+
"require": "./build/cjs/schemas.js",
|
|
28
|
+
"types": "./build/es/schemas.d.mts"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"files": [
|
|
27
32
|
"build",
|
|
28
33
|
"meta",
|
|
29
|
-
"service-plugins"
|
|
34
|
+
"service-plugins",
|
|
35
|
+
"schemas"
|
|
30
36
|
],
|
|
31
37
|
"dependencies": {
|
|
32
|
-
"@wix/sdk-runtime": "^1.0.
|
|
33
|
-
"@wix/sdk-types": "^1.17.
|
|
38
|
+
"@wix/sdk-runtime": "^1.0.12",
|
|
39
|
+
"@wix/sdk-types": "^1.17.7",
|
|
40
|
+
"zod": "^4.3.6"
|
|
34
41
|
},
|
|
35
42
|
"devDependencies": {
|
|
36
43
|
"tsup": "^8.4.0",
|
|
@@ -50,5 +57,5 @@
|
|
|
50
57
|
"fqdn": "wix.realtime.v4.message"
|
|
51
58
|
}
|
|
52
59
|
},
|
|
53
|
-
"falconPackageHash": "
|
|
60
|
+
"falconPackageHash": "9d606eba873604cf73358dcb02a9dd68c3c645f50d05a23f1fc6d71f"
|
|
54
61
|
}
|