@wix/auto_sdk_duplexer_publisher 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/build/cjs/index.d.ts +13 -0
  2. package/build/cjs/index.js +109 -0
  3. package/build/cjs/index.js.map +1 -0
  4. package/build/cjs/index.typings.d.ts +94 -0
  5. package/build/cjs/index.typings.js +95 -0
  6. package/build/cjs/index.typings.js.map +1 -0
  7. package/build/cjs/meta.d.ts +85 -0
  8. package/build/cjs/meta.js +79 -0
  9. package/build/cjs/meta.js.map +1 -0
  10. package/build/es/index.d.mts +13 -0
  11. package/build/es/index.mjs +82 -0
  12. package/build/es/index.mjs.map +1 -0
  13. package/build/es/index.typings.d.mts +94 -0
  14. package/build/es/index.typings.mjs +68 -0
  15. package/build/es/index.typings.mjs.map +1 -0
  16. package/build/es/meta.d.mts +85 -0
  17. package/build/es/meta.mjs +52 -0
  18. package/build/es/meta.mjs.map +1 -0
  19. package/build/es/package.json +3 -0
  20. package/build/internal/cjs/index.d.ts +13 -0
  21. package/build/internal/cjs/index.js +109 -0
  22. package/build/internal/cjs/index.js.map +1 -0
  23. package/build/internal/cjs/index.typings.d.ts +94 -0
  24. package/build/internal/cjs/index.typings.js +95 -0
  25. package/build/internal/cjs/index.typings.js.map +1 -0
  26. package/build/internal/cjs/meta.d.ts +85 -0
  27. package/build/internal/cjs/meta.js +79 -0
  28. package/build/internal/cjs/meta.js.map +1 -0
  29. package/build/internal/es/index.d.mts +13 -0
  30. package/build/internal/es/index.mjs +82 -0
  31. package/build/internal/es/index.mjs.map +1 -0
  32. package/build/internal/es/index.typings.d.mts +94 -0
  33. package/build/internal/es/index.typings.mjs +68 -0
  34. package/build/internal/es/index.typings.mjs.map +1 -0
  35. package/build/internal/es/meta.d.mts +85 -0
  36. package/build/internal/es/meta.mjs +52 -0
  37. package/build/internal/es/meta.mjs.map +1 -0
  38. package/meta/package.json +3 -0
  39. package/package.json +54 -0
@@ -0,0 +1,13 @@
1
+ import { HttpClient, NonNullablePaths, MaybeContext, BuildRESTFunction } from '@wix/sdk-types';
2
+ import { Message, PublishOptions } from './index.typings.js';
3
+ export { PublishRequest, PublishResponse, PublishToUserRequest, PublishToUserRequestTargetingOneOf, PublishToUserResponse, PublisherInfo, UserIdList } from './index.typings.js';
4
+
5
+ declare function publish$1(httpClient: HttpClient): PublishSignature;
6
+ interface PublishSignature {
7
+ /** */
8
+ (message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
9
+ }
10
+
11
+ declare const publish: MaybeContext<BuildRESTFunction<typeof publish$1> & typeof publish$1>;
12
+
13
+ export { Message, PublishOptions, publish };
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ publish: () => publish4
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/realtime-v4-message-publisher.universal.ts
28
+ var import_transform_error = require("@wix/sdk-runtime/transform-error");
29
+ var import_rename_all_nested_keys = require("@wix/sdk-runtime/rename-all-nested-keys");
30
+
31
+ // src/realtime-v4-message-publisher.http.ts
32
+ var import_rest_modules = require("@wix/sdk-runtime/rest-modules");
33
+ function resolveComWixRealtimeV4DuplexerApiV4Url(opts) {
34
+ const domainToMappings = {};
35
+ return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
36
+ }
37
+ var PACKAGE_NAME = "@wix/auto_sdk_duplexer_publisher";
38
+ function publish(payload) {
39
+ function __publish({ host }) {
40
+ const metadata = {
41
+ entityFqdn: "wix.realtime.v4.message",
42
+ method: "POST",
43
+ methodFqn: "com.wix.realtime.v4.DuplexerApiV4.Publish",
44
+ packageName: PACKAGE_NAME,
45
+ migrationOptions: {
46
+ optInTransformResponse: true
47
+ },
48
+ url: resolveComWixRealtimeV4DuplexerApiV4Url({
49
+ protoPath: "/publish",
50
+ data: payload,
51
+ host
52
+ }),
53
+ data: payload
54
+ };
55
+ return metadata;
56
+ }
57
+ return __publish;
58
+ }
59
+
60
+ // src/realtime-v4-message-publisher.universal.ts
61
+ async function publish2(message, options) {
62
+ const { httpClient, sideEffects } = arguments[2];
63
+ const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
64
+ message,
65
+ channels: options?.channels,
66
+ resourceId: options?.resourceId
67
+ });
68
+ const reqOpts = publish(payload);
69
+ sideEffects?.onSiteCall?.();
70
+ try {
71
+ const result = await httpClient.request(reqOpts);
72
+ sideEffects?.onSuccess?.(result);
73
+ } catch (err) {
74
+ const transformedError = (0, import_transform_error.transformError)(
75
+ err,
76
+ {
77
+ spreadPathsToArguments: {},
78
+ explicitPathsToArguments: {
79
+ message: "$[0]",
80
+ channels: "$[1].channels",
81
+ resourceId: "$[1].resourceId"
82
+ },
83
+ singleArgumentUnchanged: false
84
+ },
85
+ ["message", "options"]
86
+ );
87
+ sideEffects?.onError?.(err);
88
+ throw transformedError;
89
+ }
90
+ }
91
+
92
+ // src/realtime-v4-message-publisher.public.ts
93
+ function publish3(httpClient) {
94
+ return (message, options) => publish2(
95
+ message,
96
+ options,
97
+ // @ts-ignore
98
+ { httpClient }
99
+ );
100
+ }
101
+
102
+ // src/realtime-v4-message-publisher.context.ts
103
+ var import_rest_modules2 = require("@wix/sdk-runtime/rest-modules");
104
+ var publish4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(publish3);
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ publish
108
+ });
109
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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\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: '/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,CAAC;AAE1B,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;;;ADoDA,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;;;AEvHO,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"]}
@@ -0,0 +1,94 @@
1
+ import { NonNullablePaths } from '@wix/sdk-types';
2
+
3
+ interface Message {
4
+ /**
5
+ * Unique message identifier
6
+ * @readonly
7
+ * @format GUID
8
+ */
9
+ _id?: string;
10
+ /**
11
+ * Event name, e.g "product_added"
12
+ * @maxLength 1000
13
+ */
14
+ eventName?: string;
15
+ /** Event payload, e.g { "product_id": "123", "product_name": "Product 1" } */
16
+ payload?: Record<string, any> | null;
17
+ /** Info regarding the publisher of the message */
18
+ publisherInfo?: PublisherInfo;
19
+ }
20
+ interface PublisherInfo {
21
+ /**
22
+ * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher
23
+ * @maxLength 1000
24
+ */
25
+ uid?: string;
26
+ }
27
+ interface PublishRequest {
28
+ message: Message;
29
+ /**
30
+ * Channel names to publish to, e.g ["product_notifications", "site_notifications"]
31
+ * @maxSize 10
32
+ * @maxLength 140
33
+ */
34
+ channels: string[];
35
+ /**
36
+ * Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message
37
+ * @maxLength 1000
38
+ */
39
+ resourceId?: string | null;
40
+ }
41
+ interface PublishResponse {
42
+ }
43
+ interface PublishToUserRequest extends PublishToUserRequestTargetingOneOf {
44
+ /** list of user ids to receive the message */
45
+ includeRecipients?: UserIdList;
46
+ /** list of user ids to exclude from receiving the message */
47
+ excludeRecipients?: UserIdList;
48
+ message?: Message;
49
+ /**
50
+ * Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message
51
+ * @maxLength 1000
52
+ */
53
+ resourceId?: string | null;
54
+ }
55
+ /** @oneof */
56
+ interface PublishToUserRequestTargetingOneOf {
57
+ /** list of user ids to receive the message */
58
+ includeRecipients?: UserIdList;
59
+ /** list of user ids to exclude from receiving the message */
60
+ excludeRecipients?: UserIdList;
61
+ }
62
+ interface UserIdList {
63
+ /**
64
+ * @maxSize 1000
65
+ * @maxLength 1000
66
+ */
67
+ userId?: string[];
68
+ }
69
+ interface PublishToUserResponse {
70
+ }
71
+ /** @public
72
+ * @requiredField message
73
+ * @requiredField message.eventName
74
+ * @requiredField message.payload
75
+ * @requiredField options.channels
76
+ * @permissionId realtime:v4:message:publish
77
+ * @fqn com.wix.realtime.v4.DuplexerApiV4.Publish
78
+ */
79
+ declare function publish(message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
80
+ interface PublishOptions {
81
+ /**
82
+ * Channel names to publish to, e.g ["product_notifications", "site_notifications"]
83
+ * @maxSize 10
84
+ * @maxLength 140
85
+ */
86
+ channels: string[];
87
+ /**
88
+ * Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message
89
+ * @maxLength 1000
90
+ */
91
+ resourceId?: string | null;
92
+ }
93
+
94
+ export { type Message, type PublishOptions, type PublishRequest, type PublishResponse, type PublishToUserRequest, type PublishToUserRequestTargetingOneOf, type PublishToUserResponse, type PublisherInfo, type UserIdList, publish };
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.typings.ts
21
+ var index_typings_exports = {};
22
+ __export(index_typings_exports, {
23
+ publish: () => publish2
24
+ });
25
+ module.exports = __toCommonJS(index_typings_exports);
26
+
27
+ // src/realtime-v4-message-publisher.universal.ts
28
+ var import_transform_error = require("@wix/sdk-runtime/transform-error");
29
+ var import_rename_all_nested_keys = require("@wix/sdk-runtime/rename-all-nested-keys");
30
+
31
+ // src/realtime-v4-message-publisher.http.ts
32
+ var import_rest_modules = require("@wix/sdk-runtime/rest-modules");
33
+ function resolveComWixRealtimeV4DuplexerApiV4Url(opts) {
34
+ const domainToMappings = {};
35
+ return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
36
+ }
37
+ var PACKAGE_NAME = "@wix/auto_sdk_duplexer_publisher";
38
+ function publish(payload) {
39
+ function __publish({ host }) {
40
+ const metadata = {
41
+ entityFqdn: "wix.realtime.v4.message",
42
+ method: "POST",
43
+ methodFqn: "com.wix.realtime.v4.DuplexerApiV4.Publish",
44
+ packageName: PACKAGE_NAME,
45
+ migrationOptions: {
46
+ optInTransformResponse: true
47
+ },
48
+ url: resolveComWixRealtimeV4DuplexerApiV4Url({
49
+ protoPath: "/publish",
50
+ data: payload,
51
+ host
52
+ }),
53
+ data: payload
54
+ };
55
+ return metadata;
56
+ }
57
+ return __publish;
58
+ }
59
+
60
+ // src/realtime-v4-message-publisher.universal.ts
61
+ async function publish2(message, options) {
62
+ const { httpClient, sideEffects } = arguments[2];
63
+ const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
64
+ message,
65
+ channels: options?.channels,
66
+ resourceId: options?.resourceId
67
+ });
68
+ const reqOpts = publish(payload);
69
+ sideEffects?.onSiteCall?.();
70
+ try {
71
+ const result = await httpClient.request(reqOpts);
72
+ sideEffects?.onSuccess?.(result);
73
+ } catch (err) {
74
+ const transformedError = (0, import_transform_error.transformError)(
75
+ err,
76
+ {
77
+ spreadPathsToArguments: {},
78
+ explicitPathsToArguments: {
79
+ message: "$[0]",
80
+ channels: "$[1].channels",
81
+ resourceId: "$[1].resourceId"
82
+ },
83
+ singleArgumentUnchanged: false
84
+ },
85
+ ["message", "options"]
86
+ );
87
+ sideEffects?.onError?.(err);
88
+ throw transformedError;
89
+ }
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ publish
94
+ });
95
+ //# sourceMappingURL=index.typings.js.map
@@ -0,0 +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\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: '/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,CAAC;AAE1B,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;;;ADoDA,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,85 @@
1
+ import { PublishRequest as PublishRequest$1, PublishResponse as PublishResponse$1 } from './index.typings.js';
2
+ import '@wix/sdk-types';
3
+
4
+ interface Message {
5
+ /**
6
+ * Unique message identifier
7
+ * @readonly
8
+ * @format GUID
9
+ */
10
+ id?: string;
11
+ /**
12
+ * Event name, e.g "product_added"
13
+ * @maxLength 1000
14
+ */
15
+ eventName?: string;
16
+ /** Event payload, e.g { "product_id": "123", "product_name": "Product 1" } */
17
+ payload?: Record<string, any> | null;
18
+ /** Info regarding the publisher of the message */
19
+ publisherInfo?: PublisherInfo;
20
+ }
21
+ interface PublisherInfo {
22
+ /**
23
+ * Arbitrary string identifier for the publisher, can be used by subscribers to identify the publisher
24
+ * @maxLength 1000
25
+ */
26
+ uid?: string;
27
+ }
28
+ interface PublishRequest {
29
+ message: Message;
30
+ /**
31
+ * Channel names to publish to, e.g ["product_notifications", "site_notifications"]
32
+ * @maxSize 10
33
+ * @maxLength 140
34
+ */
35
+ channels: string[];
36
+ /**
37
+ * Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message
38
+ * @maxLength 1000
39
+ */
40
+ resourceId?: string | null;
41
+ }
42
+ interface PublishResponse {
43
+ }
44
+ interface PublishToUserRequest extends PublishToUserRequestTargetingOneOf {
45
+ /** list of user ids to receive the message */
46
+ includeRecipients?: UserIdList;
47
+ /** list of user ids to exclude from receiving the message */
48
+ excludeRecipients?: UserIdList;
49
+ message?: Message;
50
+ /**
51
+ * Optional sub resource identifier, e.g "important_notification", only subscribers to this specific resource will receive the message
52
+ * @maxLength 1000
53
+ */
54
+ resourceId?: string | null;
55
+ }
56
+ /** @oneof */
57
+ interface PublishToUserRequestTargetingOneOf {
58
+ /** list of user ids to receive the message */
59
+ includeRecipients?: UserIdList;
60
+ /** list of user ids to exclude from receiving the message */
61
+ excludeRecipients?: UserIdList;
62
+ }
63
+ interface UserIdList {
64
+ /**
65
+ * @maxSize 1000
66
+ * @maxLength 1000
67
+ */
68
+ userId?: string[];
69
+ }
70
+ interface PublishToUserResponse {
71
+ }
72
+
73
+ type __PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q = unknown, R = unknown> = {
74
+ getUrl: (context: any) => string;
75
+ httpMethod: K;
76
+ path: string;
77
+ pathParams: M;
78
+ __requestType: T;
79
+ __originalRequestType: S;
80
+ __responseType: Q;
81
+ __originalResponseType: R;
82
+ };
83
+ declare function publish(): __PublicMethodMetaInfo<'POST', {}, PublishRequest$1, PublishRequest, PublishResponse$1, PublishResponse>;
84
+
85
+ export { type Message as MessageOriginal, type PublishRequest as PublishRequestOriginal, type PublishResponse as PublishResponseOriginal, type PublishToUserRequest as PublishToUserRequestOriginal, type PublishToUserRequestTargetingOneOf as PublishToUserRequestTargetingOneOfOriginal, type PublishToUserResponse as PublishToUserResponseOriginal, type PublisherInfo as PublisherInfoOriginal, type UserIdList as UserIdListOriginal, type __PublicMethodMetaInfo, publish };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // meta.ts
21
+ var meta_exports = {};
22
+ __export(meta_exports, {
23
+ publish: () => publish2
24
+ });
25
+ module.exports = __toCommonJS(meta_exports);
26
+
27
+ // src/realtime-v4-message-publisher.http.ts
28
+ var import_rest_modules = require("@wix/sdk-runtime/rest-modules");
29
+ function resolveComWixRealtimeV4DuplexerApiV4Url(opts) {
30
+ const domainToMappings = {};
31
+ return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
32
+ }
33
+ var PACKAGE_NAME = "@wix/auto_sdk_duplexer_publisher";
34
+ function publish(payload) {
35
+ function __publish({ host }) {
36
+ const metadata = {
37
+ entityFqdn: "wix.realtime.v4.message",
38
+ method: "POST",
39
+ methodFqn: "com.wix.realtime.v4.DuplexerApiV4.Publish",
40
+ packageName: PACKAGE_NAME,
41
+ migrationOptions: {
42
+ optInTransformResponse: true
43
+ },
44
+ url: resolveComWixRealtimeV4DuplexerApiV4Url({
45
+ protoPath: "/publish",
46
+ data: payload,
47
+ host
48
+ }),
49
+ data: payload
50
+ };
51
+ return metadata;
52
+ }
53
+ return __publish;
54
+ }
55
+
56
+ // src/realtime-v4-message-publisher.meta.ts
57
+ function publish2() {
58
+ const payload = {};
59
+ const getRequestOptions = publish(payload);
60
+ const getUrl = (context) => {
61
+ const { url } = getRequestOptions(context);
62
+ return url;
63
+ };
64
+ return {
65
+ getUrl,
66
+ httpMethod: "POST",
67
+ path: "/publish",
68
+ pathParams: {},
69
+ __requestType: null,
70
+ __originalRequestType: null,
71
+ __responseType: null,
72
+ __originalResponseType: null
73
+ };
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ publish
78
+ });
79
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../meta.ts","../../src/realtime-v4-message-publisher.http.ts","../../src/realtime-v4-message-publisher.meta.ts"],"sourcesContent":["export * from './src/realtime-v4-message-publisher.meta.js';\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\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: '/publish',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __publish;\n}\n","import * as ambassadorWixRealtimeV4Message from './realtime-v4-message-publisher.http.js';\nimport * as ambassadorWixRealtimeV4MessageTypes from './realtime-v4-message-publisher.types.js';\nimport * as ambassadorWixRealtimeV4MessageUniversalTypes from './realtime-v4-message-publisher.universal.js';\n\nexport type __PublicMethodMetaInfo<\n K = string,\n M = unknown,\n T = unknown,\n S = unknown,\n Q = unknown,\n R = unknown\n> = {\n getUrl: (context: any) => string;\n httpMethod: K;\n path: string;\n pathParams: M;\n __requestType: T;\n __originalRequestType: S;\n __responseType: Q;\n __originalResponseType: R;\n};\n\nexport function publish(): __PublicMethodMetaInfo<\n 'POST',\n {},\n ambassadorWixRealtimeV4MessageUniversalTypes.PublishRequest,\n ambassadorWixRealtimeV4MessageTypes.PublishRequest,\n ambassadorWixRealtimeV4MessageUniversalTypes.PublishResponse,\n ambassadorWixRealtimeV4MessageTypes.PublishResponse\n> {\n const payload = {} as any;\n\n const getRequestOptions = ambassadorWixRealtimeV4Message.publish(payload);\n\n const getUrl = (context: any): string => {\n const { url } = getRequestOptions(context);\n return url!;\n };\n\n return {\n getUrl,\n httpMethod: 'POST',\n path: '/publish',\n pathParams: {},\n __requestType: null as any,\n __originalRequestType: null as any,\n __responseType: null as any,\n __originalResponseType: null as any,\n };\n}\n\nexport {\n Message as MessageOriginal,\n PublisherInfo as PublisherInfoOriginal,\n PublishRequest as PublishRequestOriginal,\n PublishResponse as PublishResponseOriginal,\n PublishToUserRequest as PublishToUserRequestOriginal,\n PublishToUserRequestTargetingOneOf as PublishToUserRequestTargetingOneOfOriginal,\n UserIdList as UserIdListOriginal,\n PublishToUserResponse as PublishToUserResponseOriginal,\n} from './realtime-v4-message-publisher.types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,0BAA2B;AAI3B,SAAS,wCACP,MACA;AACA,QAAM,mBAAmB,CAAC;AAE1B,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;;;ACdO,SAASC,WAOd;AACA,QAAM,UAAU,CAAC;AAEjB,QAAM,oBAAmD,QAAQ,OAAO;AAExE,QAAM,SAAS,CAAC,YAAyB;AACvC,UAAM,EAAE,IAAI,IAAI,kBAAkB,OAAO;AACzC,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,YAAY,CAAC;AAAA,IACb,eAAe;AAAA,IACf,uBAAuB;AAAA,IACvB,gBAAgB;AAAA,IAChB,wBAAwB;AAAA,EAC1B;AACF;","names":["publish","publish"]}
@@ -0,0 +1,13 @@
1
+ import { HttpClient, NonNullablePaths, MaybeContext, BuildRESTFunction } from '@wix/sdk-types';
2
+ import { Message, PublishOptions } from './index.typings.mjs';
3
+ export { PublishRequest, PublishResponse, PublishToUserRequest, PublishToUserRequestTargetingOneOf, PublishToUserResponse, PublisherInfo, UserIdList } from './index.typings.mjs';
4
+
5
+ declare function publish$1(httpClient: HttpClient): PublishSignature;
6
+ interface PublishSignature {
7
+ /** */
8
+ (message: NonNullablePaths<Message, `eventName` | `payload`, 2>, options?: NonNullablePaths<PublishOptions, `channels`, 2>): Promise<void>;
9
+ }
10
+
11
+ declare const publish: MaybeContext<BuildRESTFunction<typeof publish$1> & typeof publish$1>;
12
+
13
+ export { Message, PublishOptions, publish };
@@ -0,0 +1,82 @@
1
+ // src/realtime-v4-message-publisher.universal.ts
2
+ import { transformError as sdkTransformError } from "@wix/sdk-runtime/transform-error";
3
+ import { renameKeysFromSDKRequestToRESTRequest } from "@wix/sdk-runtime/rename-all-nested-keys";
4
+
5
+ // src/realtime-v4-message-publisher.http.ts
6
+ import { resolveUrl } from "@wix/sdk-runtime/rest-modules";
7
+ function resolveComWixRealtimeV4DuplexerApiV4Url(opts) {
8
+ const domainToMappings = {};
9
+ return resolveUrl(Object.assign(opts, { domainToMappings }));
10
+ }
11
+ var PACKAGE_NAME = "@wix/auto_sdk_duplexer_publisher";
12
+ function publish(payload) {
13
+ function __publish({ host }) {
14
+ const metadata = {
15
+ entityFqdn: "wix.realtime.v4.message",
16
+ method: "POST",
17
+ methodFqn: "com.wix.realtime.v4.DuplexerApiV4.Publish",
18
+ packageName: PACKAGE_NAME,
19
+ migrationOptions: {
20
+ optInTransformResponse: true
21
+ },
22
+ url: resolveComWixRealtimeV4DuplexerApiV4Url({
23
+ protoPath: "/publish",
24
+ data: payload,
25
+ host
26
+ }),
27
+ data: payload
28
+ };
29
+ return metadata;
30
+ }
31
+ return __publish;
32
+ }
33
+
34
+ // src/realtime-v4-message-publisher.universal.ts
35
+ async function publish2(message, options) {
36
+ const { httpClient, sideEffects } = arguments[2];
37
+ const payload = renameKeysFromSDKRequestToRESTRequest({
38
+ message,
39
+ channels: options?.channels,
40
+ resourceId: options?.resourceId
41
+ });
42
+ const reqOpts = publish(payload);
43
+ sideEffects?.onSiteCall?.();
44
+ try {
45
+ const result = await httpClient.request(reqOpts);
46
+ sideEffects?.onSuccess?.(result);
47
+ } catch (err) {
48
+ const transformedError = sdkTransformError(
49
+ err,
50
+ {
51
+ spreadPathsToArguments: {},
52
+ explicitPathsToArguments: {
53
+ message: "$[0]",
54
+ channels: "$[1].channels",
55
+ resourceId: "$[1].resourceId"
56
+ },
57
+ singleArgumentUnchanged: false
58
+ },
59
+ ["message", "options"]
60
+ );
61
+ sideEffects?.onError?.(err);
62
+ throw transformedError;
63
+ }
64
+ }
65
+
66
+ // src/realtime-v4-message-publisher.public.ts
67
+ function publish3(httpClient) {
68
+ return (message, options) => publish2(
69
+ message,
70
+ options,
71
+ // @ts-ignore
72
+ { httpClient }
73
+ );
74
+ }
75
+
76
+ // src/realtime-v4-message-publisher.context.ts
77
+ import { createRESTModule } from "@wix/sdk-runtime/rest-modules";
78
+ var publish4 = /* @__PURE__ */ createRESTModule(publish3);
79
+ export {
80
+ publish4 as publish
81
+ };
82
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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\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: '/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,CAAC;AAE1B,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;;;ADoDA,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;;;AEvHO,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"]}