@crvouga/mockingbird-service-sns 1.15.0 → 1.16.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.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,22 @@
1
1
  # Changelog — @crvouga/mockingbird-service-sns
2
2
 
3
- ## 1.15.0 (2026-11-14)
3
+ ## 1.16.0 (2026-11-14)
4
4
 
5
5
  ### Features
6
6
 
7
+ - expand in-process emulation and resolve Plane and streaming gaps ([e6733fd](https://github.com/crvouga/mockingbird/commit/e6733fd00f5dd03259f36cc0f452780a7e0deea4))
8
+ - add browser runtime polyfills and edge-snapping app cycle ([815b739](https://github.com/crvouga/mockingbird/commit/815b7399f1e058b89b3fa025f79a5014172b3ab8))
9
+ - run lab systems in browser PR previews ([df14882](https://github.com/crvouga/mockingbird/commit/df148828ca66db1e20cf9fa2fdf38b56b5116da4))
10
+
11
+ ### Dependencies
12
+
13
+ - `@crvouga/mockingbird-runtime`
14
+
15
+ ## 1.15.0 (2026-11-13)
16
+
17
+ ### Features
18
+
19
+ - publish the shared runtime once; services depend on it instead of inlining it ([4903c4a](https://github.com/crvouga/mockingbird/commit/4903c4a748fd801001ad3fd34b6016b55e0f9953))
7
20
  - add transcript storage, signature and meetings; tags, teams, messages, macros and calls ([ee21e12](https://github.com/crvouga/mockingbird/commit/ee21e12024768bd52c6902b1722fb35a94d2444b))
8
21
 
9
22
  ## 1.14.0 (2026-11-12)
@@ -0,0 +1,31 @@
1
+ import {
2
+ createRuntime
3
+ } from "./chunk-R3ZSEUIJ.js";
4
+
5
+ // src/server.ts
6
+ import { listen } from "@crvouga/mockingbird-runtime/adapter-node";
7
+ var DEFAULT_PORT = 8902;
8
+ var createServer = async (options = {}) => {
9
+ const { port, host, ...rest } = options;
10
+ const runtime = createRuntime(rest);
11
+ return { ...await listen(runtime, { port: port ?? 0, ...host ? { host } : {} }), runtime };
12
+ };
13
+ var serveTarget = {
14
+ name: "sns",
15
+ defaultPort: DEFAULT_PORT,
16
+ create: (_values, common) => createRuntime({
17
+ ...common.adminPrefix !== void 0 ? { adminPrefix: common.adminPrefix } : {},
18
+ ...common.adminKey !== void 0 ? { adminKey: common.adminKey } : {},
19
+ ...common.adminControls !== void 0 ? { adminControls: common.adminControls } : {},
20
+ ...common.seed !== void 0 ? { seed: common.seed } : {},
21
+ ...common.onLog ? { onLog: common.onLog } : {}
22
+ }),
23
+ banner: () => ["Point the AWS SDK endpoint at this server"]
24
+ };
25
+
26
+ export {
27
+ DEFAULT_PORT,
28
+ createServer,
29
+ serveTarget
30
+ };
31
+ //# sourceMappingURL=chunk-OE6OFGUC.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/server.ts"],
4
+ "sourcesContent": ["/// <reference types=\"node\" />\nimport { type Listening, listen, type ServeTarget } from \"@crvouga/mockingbird-adapter-node\"\nimport { createRuntime, type Runtime, type RuntimeOptions } from \"./runtime.js\"\nexport const DEFAULT_PORT = 8902\nexport type ServerOptions = RuntimeOptions & { port?: number; host?: string }\nexport const createServer = async (\n options: ServerOptions = {},\n): Promise<Listening & { runtime: Runtime }> => {\n const { port, host, ...rest } = options\n const runtime = createRuntime(rest)\n return { ...(await listen(runtime, { port: port ?? 0, ...(host ? { host } : {}) })), runtime }\n}\nexport const serveTarget: ServeTarget = {\n name: \"sns\",\n defaultPort: DEFAULT_PORT,\n create: (_values, common) =>\n createRuntime({\n ...(common.adminPrefix !== undefined ? { adminPrefix: common.adminPrefix } : {}),\n ...(common.adminKey !== undefined ? { adminKey: common.adminKey } : {}),\n ...(common.adminControls !== undefined ? { adminControls: common.adminControls } : {}),\n ...(common.seed !== undefined ? { seed: common.seed } : {}),\n ...(common.onLog ? { onLog: common.onLog } : {}),\n }),\n banner: () => [\"Point the AWS SDK endpoint at this server\"],\n}\n"],
5
+ "mappings": ";;;;;AACA,SAAyB,cAAgC;AAElD,IAAM,eAAe;AAErB,IAAM,eAAe,OAC1B,UAAyB,CAAC,MACoB;AAC9C,QAAM,EAAE,MAAM,MAAM,GAAG,KAAK,IAAI;AAChC,QAAM,UAAU,cAAc,IAAI;AAClC,SAAO,EAAE,GAAI,MAAM,OAAO,SAAS,EAAE,MAAM,QAAQ,GAAG,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC,EAAG,CAAC,GAAI,QAAQ;AAC/F;AACO,IAAM,cAA2B;AAAA,EACtC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,QAAQ,CAAC,SAAS,WAChB,cAAc;AAAA,IACZ,GAAI,OAAO,gBAAgB,SAAY,EAAE,aAAa,OAAO,YAAY,IAAI,CAAC;AAAA,IAC9E,GAAI,OAAO,aAAa,SAAY,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;AAAA,IACrE,GAAI,OAAO,kBAAkB,SAAY,EAAE,eAAe,OAAO,cAAc,IAAI,CAAC;AAAA,IACpF,GAAI,OAAO,SAAS,SAAY,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,IACzD,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,EAChD,CAAC;AAAA,EACH,QAAQ,MAAM,CAAC,2CAA2C;AAC5D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,274 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
19
+ // <define:__MOCKINGBIRD_ADMIN_BRAND__>
20
+ var define_MOCKINGBIRD_ADMIN_BRAND_default = { vendor: "Amazon Web Services", website: "https://aws.amazon.com/", docs: "https://docs.aws.amazon.com/", guide: "https://mockingbird.chrisvouga.dev/services/sns", logo: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAACXBIWXMAAAsSAAALEgHS3X78AAALp0lEQVR4nO2dT0hbWx7Hf52ZZZLFm/cgE4VZTCSkm9FHIBs7PKGCfY+68A9dZBOpC2VQcWGLKGWQSmldSO1CZ6joJvMIT7tQxgoRUscwkEcYAwMVaZYqwvBmkWQzbzOziEdv7j33T/yZexL7/aza5N6b672fe87v/M6fe+d3v//D/wiAa/IL1ScAmhsIBFhAIMACAgEWEAiwgECABQQCLCAQYAGBAAsIBFhAIMACAgEWEAiwgECABQQCLCAQYAGBAAsIBFhAIMACAgEWEAiwgECABQQCLCAQYAGBAAsIBFhAIMACAgEWEAiwgECABQQCLCAQYAGBAAsIBFhAIMACAgEWEAiwgECABQQCLCAQYAGBAAsIBFhAIMACAgEWv1J9AlrCoSBFI+10N9RGLQG/dJtsLk9Hx58olc64fHbu0N3VSeFQG0Uj7YbvTs/O6ePxp4trUFBwdkbuqH5bT2vAT/HYIHV3dZpKI6NYKtN6YoOWVtak3y8vzlN3V2fVZ6l0hkYnZxwdf3ZqjOKxgarPTs/O6eGjx1QslW33D4eClHj7mnxeT9Xn33z7iE7Ozg3bx2MDNBQbdHwNiqUyvdvapaWVNUfnUy+UVmGzU2P0YSdJ8dhATfIQEfm8HhofidN2ctVwk4iISpKLWnm6g46OrZeHiKgl4DdIacZQbFB6Xnp5fF4PbSdXaXZqrKZrIM4x8fa1433qgTKBwqGg9CZd5zjLi/OGz7O5Q+n2sqpBdkwzopEOR+cl+x19tePzeijx9rUjqc0Q1b4qlMVAsq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HTnRphzpcTXCmBRN9VX28PtQT89HJumsZHhmhpZU15X06jIVafJaqM8SmWyqarkYjYyGqpvHrjaiZ6fGTIMPrv9OwcIjGRDY95vvCm5s7q6+BqM35pZY1GJ2eqYiBRIu3vJGl8ZKiuU5xvK7IWl1tDXF3PA6XSGenkwZaAn8ZH4vRhJ0mv5qabao0cN4hG2ml5cZ4K+X3a30lWjXmSXSu3Ol2VjYmODU9Ii1ixgIB2qOfnWiq1Bvw0PjJE+ztJSrx9fdmcbwn4q4Js/bI0bg4wU94b393VSS/nph0Mhq/Ml69lvnkz4mRuvHgAxXXQD7F1c6CZcoGIKqXO7NSY6ThjPdlcnlLpA1czrvVEzEhxsqCCeD+I9iH658Hfqh7Ar+9959pD1hACCaKRdno1N13TCqZiFdVs7vBay+SqoPWiChKzWp38vWYLkIsl8QTvtnYv0yZu0FACCcZHhq4d+1ReiVS4GL13ePmqAFVoRxpejbqsbSXWpZV10wy+vvoyextQvWhIgYicL33nBJGIEzKJgfM3KddVJ2fHpTRma0Y7RbzOyUoIbfW1ntiwne1y0zSsQIKbFMkKWbNX+3oCp4tq3gROxCG6mmwoztXpu8xukoYXSCBE6r/oDrltiAU0nYgjEBMk7RbmqidNI5CW/t4e6ut90DQdjlYcHRdoPfFDzekJ0X2hUh6iJhVIUOt6go2CmMu+ufX+2jdelMip9IHSF640tUBahExmC0apRrzeSvUNv2lujUB6tG8/ViGUeEXC0cVblm9r9vzWCqRHNKvDobYbfX2kkKOSJvh0+ZrKz4XPRiArZPkasSY10dXALkEtr5u67UAgwALzwgALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQCL/wMxYZPhdjCdcgAAAABJRU5ErkJggg==", color: "#FF9900", description: "Simple Notification Service public AWS API." };
21
+
22
+ // mockingbird-service-runtime:@crvouga/mockingbird-runtime/service
23
+ var service_exports = {};
24
+ __export(service_exports, {
25
+ PACKAGE_VERSION: () => PACKAGE_VERSION,
26
+ createRuntime: () => createRuntime
27
+ });
28
+ __reExport(service_exports, service_star);
29
+ import * as service_star from "@crvouga/mockingbird-runtime/service";
30
+ import { PACKAGE_VERSION as SHARED_VERSION, createRuntime as sharedRuntime } from "@crvouga/mockingbird-runtime/service";
31
+ var PACKAGE_VERSION = true ? "1.16.0" : SHARED_VERSION;
32
+ var ADMIN_BRAND = typeof define_MOCKINGBIRD_ADMIN_BRAND_default === "object" ? define_MOCKINGBIRD_ADMIN_BRAND_default : void 0;
33
+ var createRuntime = (options) => sharedRuntime({
34
+ ...options,
35
+ version: options.version ?? PACKAGE_VERSION,
36
+ adminBrand: options.adminBrand ?? ADMIN_BRAND
37
+ });
38
+
39
+ // src/generated/openapi.ts
40
+ var document = JSON.parse(`{"openapi":"3.1.0","info":{"title":"Amazon Simple Notification Service (Mockingbird subset)","version":"1.0.0","description":"AWS protocol transport; README lists the implemented AWS operations."},"servers":[{"url":"https://sns.us-east-1.amazonaws.com"}],"paths":{"/":{"post":{"operationId":"AwsRpc","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS protocol response"},"400":{"description":"AWS protocol error"}}},"get":{"operationId":"AwsQuery","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS query response"}}}},"/{path}":{"parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string"}}],"get":{"operationId":"AwsRestGet","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS REST response"}}},"put":{"operationId":"AwsRestPut","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS REST response"}}},"post":{"operationId":"AwsRestPost","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS REST response"}}},"patch":{"operationId":"AwsRestPatch","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS REST response"}}},"delete":{"operationId":"AwsRestDelete","x-mockingbird":{"supported":true,"parity":{"enabled":false,"reason":"Use the stateful LocalStack scenario runner."}},"responses":{"200":{"description":"AWS REST response"}}}}}}`);
41
+ var operationIds = ["AwsQuery", "AwsRpc", "AwsRestGet", "AwsRestPut", "AwsRestPost", "AwsRestDelete", "AwsRestPatch"];
42
+ var supportedOperationIds = ["AwsQuery", "AwsRpc", "AwsRestGet", "AwsRestPut", "AwsRestPost", "AwsRestDelete", "AwsRestPatch"];
43
+
44
+ // src/runtime.ts
45
+ var createRuntime2 = (options = {}) => createRuntime({
46
+ name: "sns",
47
+ document,
48
+ credential: service_exports.sigV4AccessKeyId,
49
+ ...options.sqlite ? { sqlite: options.sqlite } : {},
50
+ ...options.clock ? { clock: options.clock } : {},
51
+ ...options.seed !== void 0 ? { seed: options.seed } : {},
52
+ ...options.adminPrefix !== void 0 ? { adminPrefix: options.adminPrefix } : {},
53
+ ...options.adminKey !== void 0 ? { adminKey: options.adminKey } : {},
54
+ ...options.adminControls !== void 0 ? { adminControls: options.adminControls } : {},
55
+ ...options.onLog ? { onLog: options.onLog } : {},
56
+ create: ({ sqlite, namespace, clock }) => new SnsAPI({
57
+ sqlite,
58
+ namespace,
59
+ now: clock.now,
60
+ ...options.region ? { region: options.region } : {},
61
+ ...options.accountId ? { accountId: options.accountId } : {}
62
+ })
63
+ });
64
+
65
+ // src/index.ts
66
+ var SnsAPI = class extends service_exports.AwsProtocolAPI {
67
+ constructor(options = {}) {
68
+ super("sns", options);
69
+ }
70
+ dispatch({ operation, input }) {
71
+ if (![
72
+ "CreateTopic",
73
+ "DeleteTopic",
74
+ "ListTopics",
75
+ "GetTopicAttributes",
76
+ "SetTopicAttributes",
77
+ "Subscribe",
78
+ "Unsubscribe",
79
+ "ListSubscriptions",
80
+ "ListSubscriptionsByTopic",
81
+ "GetSubscriptionAttributes",
82
+ "SetSubscriptionAttributes",
83
+ "ConfirmSubscription",
84
+ "Publish",
85
+ "PublishBatch",
86
+ "TagResource",
87
+ "UntagResource",
88
+ "ListTagsForResource"
89
+ ].includes(operation))
90
+ return this.unsupported(operation);
91
+ const topics = this.collection("topics"), subscriptions = this.collection("subscriptions");
92
+ if (operation === "CreateTopic") {
93
+ const name = (0, service_exports.awsRequired)(input, "Name");
94
+ if (!/^[\w-]{1,256}(\.fifo)?$/.test(name))
95
+ throw new service_exports.AwsError("InvalidParameter", "Invalid topic name");
96
+ const arn = this.arn("", name, "sns");
97
+ if (!topics.has(arn))
98
+ topics.insert(arn, {
99
+ TopicArn: arn,
100
+ Name: name,
101
+ Attributes: Object.fromEntries(
102
+ (0, service_exports.awsList)(input.Attributes).map(service_exports.awsRecord).map((item) => [String(item.key), String(item.value)])
103
+ ),
104
+ Tags: input.Tags ?? []
105
+ });
106
+ return { TopicArn: arn };
107
+ }
108
+ if (operation === "ListTopics") {
109
+ const page = (0, service_exports.awsPage)(
110
+ topics.list({ order: "oldest" }).map(({ id: id2 }) => ({ TopicArn: id2 })),
111
+ input
112
+ );
113
+ return { Topics: page.items, ...page.token ? { NextToken: page.token } : {} };
114
+ }
115
+ if (["ListSubscriptions", "ListSubscriptionsByTopic"].includes(operation)) {
116
+ const page = (0, service_exports.awsPage)(
117
+ subscriptions.list({
118
+ order: "oldest",
119
+ where: (item) => operation === "ListSubscriptions" || item.TopicArn === input.TopicArn
120
+ }).map(({ value }) => value),
121
+ input
122
+ );
123
+ return { Subscriptions: page.items, ...page.token ? { NextToken: page.token } : {} };
124
+ }
125
+ if (operation === "Unsubscribe") {
126
+ subscriptions.delete((0, service_exports.awsRequired)(input, "SubscriptionArn"));
127
+ return {};
128
+ }
129
+ if (["GetSubscriptionAttributes", "SetSubscriptionAttributes"].includes(operation)) {
130
+ const id2 = (0, service_exports.awsRequired)(input, "SubscriptionArn"), item = this.get("subscriptions", id2, "NotFound");
131
+ if (operation === "GetSubscriptionAttributes")
132
+ return {
133
+ Attributes: {
134
+ ...(0, service_exports.awsRecord)(item.Attributes),
135
+ SubscriptionArn: id2,
136
+ TopicArn: item.TopicArn,
137
+ Protocol: item.Protocol,
138
+ Endpoint: item.Endpoint,
139
+ Owner: this.accountId,
140
+ PendingConfirmation: "false",
141
+ ConfirmationWasAuthenticated: "true"
142
+ }
143
+ };
144
+ subscriptions.insert(id2, {
145
+ ...item,
146
+ Attributes: {
147
+ ...(0, service_exports.awsRecord)(item.Attributes),
148
+ [(0, service_exports.awsRequired)(input, "AttributeName")]: input.AttributeValue
149
+ }
150
+ });
151
+ return {};
152
+ }
153
+ if (operation === "Publish" && input.PhoneNumber !== void 0 && !input.TopicArn) {
154
+ const phone = String(input.PhoneNumber);
155
+ if (!/^\+[1-9]\d{1,14}$/.test(phone))
156
+ throw new service_exports.AwsError(
157
+ "InvalidParameter",
158
+ `Invalid parameter: PhoneNumber Reason: ${phone} is not valid to publish to`
159
+ );
160
+ (0, service_exports.awsRequired)(input, "Message");
161
+ const messageId = this.ids.next("", 36);
162
+ this.collection("messages").insert(messageId, {
163
+ ...input,
164
+ MessageId: messageId,
165
+ PhoneNumber: phone,
166
+ Timestamp: this.now() / 1e3
167
+ });
168
+ return { MessageId: messageId };
169
+ }
170
+ const id = String(input.TopicArn ?? input.ResourceArn ?? ""), topic = this.get("topics", id, "NotFound");
171
+ if (operation === "DeleteTopic") {
172
+ topics.delete(id);
173
+ for (const row of subscriptions.list({ where: (item) => item.TopicArn === id }))
174
+ subscriptions.delete(row.id);
175
+ return {};
176
+ }
177
+ if (operation === "GetTopicAttributes")
178
+ return {
179
+ Attributes: {
180
+ TopicArn: id,
181
+ Owner: this.accountId,
182
+ DisplayName: "",
183
+ SubscriptionsConfirmed: String(
184
+ subscriptions.list({ where: (item) => item.TopicArn === id }).length
185
+ ),
186
+ SubscriptionsPending: "0",
187
+ SubscriptionsDeleted: "0",
188
+ ...(0, service_exports.awsRecord)(topic.Attributes)
189
+ }
190
+ };
191
+ if (operation === "SetTopicAttributes") {
192
+ topics.insert(id, {
193
+ ...topic,
194
+ Attributes: {
195
+ ...(0, service_exports.awsRecord)(topic.Attributes),
196
+ [(0, service_exports.awsRequired)(input, "AttributeName")]: input.AttributeValue
197
+ }
198
+ });
199
+ return {};
200
+ }
201
+ if (operation === "Subscribe") {
202
+ const protocol = (0, service_exports.awsRequired)(input, "Protocol"), endpoint = (0, service_exports.awsRequired)(input, "Endpoint");
203
+ const prior = subscriptions.list({
204
+ where: (item) => item.TopicArn === id && item.Protocol === protocol && item.Endpoint === endpoint
205
+ })[0];
206
+ if (prior) return { SubscriptionArn: prior.id };
207
+ const arn = `${id}:${this.ids.next("", 36)}`;
208
+ subscriptions.insert(arn, {
209
+ SubscriptionArn: arn,
210
+ TopicArn: id,
211
+ Protocol: protocol,
212
+ Endpoint: endpoint,
213
+ Owner: this.accountId,
214
+ Attributes: {}
215
+ });
216
+ return { SubscriptionArn: arn };
217
+ }
218
+ if (operation === "ConfirmSubscription")
219
+ return {
220
+ SubscriptionArn: subscriptions.list({ where: (item) => item.TopicArn === id })[0]?.id ?? `${id}:${this.ids.next("", 36)}`
221
+ };
222
+ const publish = (message) => {
223
+ (0, service_exports.awsRequired)(message, "Message");
224
+ const messageId = this.ids.next("", 36);
225
+ this.collection("messages").insert(messageId, {
226
+ ...message,
227
+ MessageId: messageId,
228
+ TopicArn: id,
229
+ Timestamp: this.now() / 1e3
230
+ });
231
+ return { MessageId: messageId };
232
+ };
233
+ if (operation === "Publish") return publish(input);
234
+ if (operation === "PublishBatch") {
235
+ const successful = [], failed = [];
236
+ for (const item of (0, service_exports.awsList)(input.PublishBatchRequestEntries).map(service_exports.awsRecord)) {
237
+ try {
238
+ successful.push({ Id: item.Id, ...publish(item) });
239
+ } catch (error) {
240
+ failed.push({
241
+ Id: item.Id,
242
+ Code: "InvalidParameter",
243
+ SenderFault: true,
244
+ Message: String(error)
245
+ });
246
+ }
247
+ }
248
+ return { Successful: successful, Failed: failed };
249
+ }
250
+ if (operation === "ListTagsForResource") return { Tags: topic.Tags ?? [] };
251
+ if (operation === "TagResource" || operation === "UntagResource") {
252
+ const incoming = operation === "TagResource" ? (0, service_exports.awsList)(input.Tags).map(service_exports.awsRecord) : [];
253
+ const removed = operation === "UntagResource" ? (0, service_exports.awsList)(input.TagKeys) : incoming.map((item) => item.Key);
254
+ topics.insert(id, {
255
+ ...topic,
256
+ Tags: [
257
+ ...(0, service_exports.awsList)(topic.Tags).map(service_exports.awsRecord).filter((item) => !removed.includes(item.Key)),
258
+ ...incoming
259
+ ]
260
+ });
261
+ return {};
262
+ }
263
+ return this.unsupported(operation);
264
+ }
265
+ };
266
+
267
+ export {
268
+ document,
269
+ operationIds,
270
+ supportedOperationIds,
271
+ createRuntime2 as createRuntime,
272
+ SnsAPI
273
+ };
274
+ //# sourceMappingURL=chunk-R3ZSEUIJ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["<define:__MOCKINGBIRD_ADMIN_BRAND__>", "mockingbird-service-runtime:@crvouga/mockingbird-runtime/service", "../src/generated/openapi.ts", "../src/runtime.ts", "../src/index.ts"],
4
+ "sourcesContent": ["{\"vendor\":\"Amazon Web Services\",\"website\":\"https://aws.amazon.com/\",\"docs\":\"https://docs.aws.amazon.com/\",\"guide\":\"https://mockingbird.chrisvouga.dev/services/sns\",\"logo\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAACXBIWXMAAAsSAAALEgHS3X78AAALp0lEQVR4nO2dT0hbWx7Hf52ZZZLFm/cgE4VZTCSkm9FHIBs7PKGCfY+68A9dZBOpC2VQcWGLKGWQSmldSO1CZ6joJvMIT7tQxgoRUscwkEcYAwMVaZYqw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ZiFdVs7vBay+SqoPWiChKzWp38vWYLkIsl8QTvtnYv0yZu0FACCcZHhq4d+1ReiVS4GL13ePmqAFVoRxpejbqsbSXWpZV10wy+vvoyextQvWhIgYicL33nBJGIEzKJgfM3KddVJ2fHpTRma0Y7RbzOyUoIbfW1ntiwne1y0zSsQIKbFMkKWbNX+3oCp4tq3gROxCG6mmwoztXpu8xukoYXSCBE6r/oDrltiAU0nYgjEBMk7RbmqidNI5CW/t4e6ut90DQdjlYcHRdoPfFDzekJ0X2hUh6iJhVIUOt6go2CmMu+ufX+2jdelMip9IHSF640tUBahExmC0apRrzeSvUNv2lujUB6tG8/ViGUeEXC0cVblm9r9vzWCqRHNKvDobYbfX2kkKOSJvh0+ZrKz4XPRiArZPkasSY10dXALkEtr5u67UAgwALzwgALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQALCARYQCDAAgIBFhAIsIBAgAUEAiwgEGABgQCL/wMxYZPhdjCdcgAAAABJRU5ErkJggg==\",\"color\":\"#FF9900\",\"description\":\"Simple Notification Service public AWS API.\"}", "export * from \"@crvouga/mockingbird-runtime/service\"\nimport { PACKAGE_VERSION as SHARED_VERSION, createRuntime as sharedRuntime } from \"@crvouga/mockingbird-runtime/service\"\nexport const PACKAGE_VERSION =\n typeof __MOCKINGBIRD_PACKAGE_VERSION__ === \"string\" ? __MOCKINGBIRD_PACKAGE_VERSION__ : SHARED_VERSION\nconst ADMIN_BRAND =\n typeof __MOCKINGBIRD_ADMIN_BRAND__ === \"object\" ? __MOCKINGBIRD_ADMIN_BRAND__ : undefined\nexport const createRuntime = (options) =>\n sharedRuntime({\n ...options,\n version: options.version ?? PACKAGE_VERSION,\n adminBrand: options.adminBrand ?? ADMIN_BRAND,\n })\n", "// Generated by @crvouga/mockingbird-openapi-codegen from openapi.yaml. Do not edit.\n\nimport type { OpenAPIDocument } from \"@crvouga/mockingbird-openapi\"\n\nexport const document: OpenAPIDocument = JSON.parse(`{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Amazon Simple Notification Service (Mockingbird subset)\",\"version\":\"1.0.0\",\"description\":\"AWS protocol transport; README lists the implemented AWS operations.\"},\"servers\":[{\"url\":\"https://sns.us-east-1.amazonaws.com\"}],\"paths\":{\"/\":{\"post\":{\"operationId\":\"AwsRpc\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS protocol response\"},\"400\":{\"description\":\"AWS protocol error\"}}},\"get\":{\"operationId\":\"AwsQuery\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS query response\"}}}},\"/{path}\":{\"parameters\":[{\"name\":\"path\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"get\":{\"operationId\":\"AwsRestGet\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS REST response\"}}},\"put\":{\"operationId\":\"AwsRestPut\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS REST response\"}}},\"post\":{\"operationId\":\"AwsRestPost\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS REST response\"}}},\"patch\":{\"operationId\":\"AwsRestPatch\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS REST response\"}}},\"delete\":{\"operationId\":\"AwsRestDelete\",\"x-mockingbird\":{\"supported\":true,\"parity\":{\"enabled\":false,\"reason\":\"Use the stateful LocalStack scenario runner.\"}},\"responses\":{\"200\":{\"description\":\"AWS REST response\"}}}}}}`) as OpenAPIDocument\n\nexport type OperationId = \"AwsQuery\" | \"AwsRpc\" | \"AwsRestGet\" | \"AwsRestPut\" | \"AwsRestPost\" | \"AwsRestDelete\" | \"AwsRestPatch\"\nexport type SupportedOperationId = \"AwsQuery\" | \"AwsRpc\" | \"AwsRestGet\" | \"AwsRestPut\" | \"AwsRestPost\" | \"AwsRestDelete\" | \"AwsRestPatch\"\nexport const operationIds = [\"AwsQuery\",\"AwsRpc\",\"AwsRestGet\",\"AwsRestPut\",\"AwsRestPost\",\"AwsRestDelete\",\"AwsRestPatch\"] as const\nexport const supportedOperationIds = [\"AwsQuery\",\"AwsRpc\",\"AwsRestGet\",\"AwsRestPut\",\"AwsRestPost\",\"AwsRestDelete\",\"AwsRestPatch\"] as const\n", "import {\n type Clock,\n type MockControls,\n type RequestLog,\n type ServiceRuntime,\n createRuntime as serviceRuntime,\n sigV4AccessKeyId,\n} from \"@crvouga/mockingbird-service\"\nimport type { SqliteClient } from \"@crvouga/mockingbird-sqlite\"\nimport { document } from \"./generated/openapi.js\"\nimport { SnsAPI } from \"./index.js\"\nexport type RuntimeOptions = {\n sqlite?: SqliteClient\n clock?: Clock\n seed?: number | string\n region?: string\n accountId?: string\n adminPrefix?: string\n adminKey?: string\n /** Admin controls to boot with: clock, latency, faults, seed, a starting snapshot. */\n adminControls?: MockControls\n onLog?: (entry: RequestLog) => void\n}\nexport type Runtime = ServiceRuntime<SnsAPI>\nexport const createRuntime = (options: RuntimeOptions = {}): Runtime =>\n serviceRuntime({\n name: \"sns\",\n document,\n credential: sigV4AccessKeyId,\n ...(options.sqlite ? { sqlite: options.sqlite } : {}),\n ...(options.clock ? { clock: options.clock } : {}),\n ...(options.seed !== undefined ? { seed: options.seed } : {}),\n ...(options.adminPrefix !== undefined ? { adminPrefix: options.adminPrefix } : {}),\n ...(options.adminKey !== undefined ? { adminKey: options.adminKey } : {}),\n ...(options.adminControls !== undefined ? { adminControls: options.adminControls } : {}),\n ...(options.onLog ? { onLog: options.onLog } : {}),\n create: ({ sqlite, namespace, clock }) =>\n new SnsAPI({\n sqlite,\n namespace,\n now: clock.now,\n ...(options.region ? { region: options.region } : {}),\n ...(options.accountId ? { accountId: options.accountId } : {}),\n }),\n })\n", "import {\n AwsError,\n type AwsInput,\n type AwsOperation,\n AwsProtocolAPI,\n type AwsProtocolOptions,\n awsList,\n awsMd5,\n awsPage,\n awsParseXml,\n awsRecord,\n awsRequired,\n awsXml,\n} from \"@crvouga/mockingbird-service\"\nimport { document, operationIds, supportedOperationIds } from \"./generated/openapi.js\"\n\nexport type { Runtime, RuntimeOptions } from \"./runtime.js\"\nexport { createRuntime } from \"./runtime.js\"\nexport { document, operationIds, supportedOperationIds }\nexport type APIOptions = AwsProtocolOptions\nexport class SnsAPI extends AwsProtocolAPI {\n constructor(options: APIOptions = {}) {\n super(\"sns\", options)\n }\n dispatch({ operation, input }: AwsOperation): unknown {\n if (\n ![\n \"CreateTopic\",\n \"DeleteTopic\",\n \"ListTopics\",\n \"GetTopicAttributes\",\n \"SetTopicAttributes\",\n \"Subscribe\",\n \"Unsubscribe\",\n \"ListSubscriptions\",\n \"ListSubscriptionsByTopic\",\n \"GetSubscriptionAttributes\",\n \"SetSubscriptionAttributes\",\n \"ConfirmSubscription\",\n \"Publish\",\n \"PublishBatch\",\n \"TagResource\",\n \"UntagResource\",\n \"ListTagsForResource\",\n ].includes(operation)\n )\n return this.unsupported(operation)\n const topics = this.collection(\"topics\"),\n subscriptions = this.collection(\"subscriptions\")\n if (operation === \"CreateTopic\") {\n const name = awsRequired(input, \"Name\")\n if (!/^[\\w-]{1,256}(\\.fifo)?$/.test(name))\n throw new AwsError(\"InvalidParameter\", \"Invalid topic name\")\n const arn = this.arn(\"\", name, \"sns\")\n if (!topics.has(arn))\n topics.insert(arn, {\n TopicArn: arn,\n Name: name,\n Attributes: Object.fromEntries(\n awsList(input.Attributes)\n .map(awsRecord)\n .map((item) => [String(item.key), String(item.value)]),\n ),\n Tags: input.Tags ?? [],\n })\n return { TopicArn: arn }\n }\n if (operation === \"ListTopics\") {\n const page = awsPage(\n topics.list({ order: \"oldest\" }).map(({ id }) => ({ TopicArn: id })),\n input,\n )\n return { Topics: page.items, ...(page.token ? { NextToken: page.token } : {}) }\n }\n if ([\"ListSubscriptions\", \"ListSubscriptionsByTopic\"].includes(operation)) {\n const page = awsPage(\n subscriptions\n .list({\n order: \"oldest\",\n where: (item) => operation === \"ListSubscriptions\" || item.TopicArn === input.TopicArn,\n })\n .map(({ value }) => value),\n input,\n )\n return { Subscriptions: page.items, ...(page.token ? { NextToken: page.token } : {}) }\n }\n if (operation === \"Unsubscribe\") {\n subscriptions.delete(awsRequired(input, \"SubscriptionArn\"))\n return {}\n }\n if ([\"GetSubscriptionAttributes\", \"SetSubscriptionAttributes\"].includes(operation)) {\n const id = awsRequired(input, \"SubscriptionArn\"),\n item = this.get(\"subscriptions\", id, \"NotFound\")\n if (operation === \"GetSubscriptionAttributes\")\n return {\n Attributes: {\n ...awsRecord(item.Attributes),\n SubscriptionArn: id,\n TopicArn: item.TopicArn,\n Protocol: item.Protocol,\n Endpoint: item.Endpoint,\n Owner: this.accountId,\n PendingConfirmation: \"false\",\n ConfirmationWasAuthenticated: \"true\",\n },\n }\n subscriptions.insert(id, {\n ...item,\n Attributes: {\n ...awsRecord(item.Attributes),\n [awsRequired(input, \"AttributeName\")]: input.AttributeValue,\n },\n })\n return {}\n }\n if (operation === \"Publish\" && input.PhoneNumber !== undefined && !input.TopicArn) {\n // Direct SMS: `Publish({ PhoneNumber, Message })` needs no topic. SNS accepts E.164 only.\n const phone = String(input.PhoneNumber)\n if (!/^\\+[1-9]\\d{1,14}$/.test(phone))\n throw new AwsError(\n \"InvalidParameter\",\n `Invalid parameter: PhoneNumber Reason: ${phone} is not valid to publish to`,\n )\n awsRequired(input, \"Message\")\n const messageId = this.ids.next(\"\", 36)\n this.collection(\"messages\").insert(messageId, {\n ...input,\n MessageId: messageId,\n PhoneNumber: phone,\n Timestamp: this.now() / 1000,\n })\n return { MessageId: messageId }\n }\n const id = String(input.TopicArn ?? input.ResourceArn ?? \"\"),\n topic = this.get(\"topics\", id, \"NotFound\")\n if (operation === \"DeleteTopic\") {\n topics.delete(id)\n for (const row of subscriptions.list({ where: (item) => item.TopicArn === id }))\n subscriptions.delete(row.id)\n return {}\n }\n if (operation === \"GetTopicAttributes\")\n return {\n Attributes: {\n TopicArn: id,\n Owner: this.accountId,\n DisplayName: \"\",\n SubscriptionsConfirmed: String(\n subscriptions.list({ where: (item) => item.TopicArn === id }).length,\n ),\n SubscriptionsPending: \"0\",\n SubscriptionsDeleted: \"0\",\n ...awsRecord(topic.Attributes),\n },\n }\n if (operation === \"SetTopicAttributes\") {\n topics.insert(id, {\n ...topic,\n Attributes: {\n ...awsRecord(topic.Attributes),\n [awsRequired(input, \"AttributeName\")]: input.AttributeValue,\n },\n })\n return {}\n }\n if (operation === \"Subscribe\") {\n const protocol = awsRequired(input, \"Protocol\"),\n endpoint = awsRequired(input, \"Endpoint\")\n const prior = subscriptions.list({\n where: (item) =>\n item.TopicArn === id && item.Protocol === protocol && item.Endpoint === endpoint,\n })[0]\n if (prior) return { SubscriptionArn: prior.id }\n const arn = `${id}:${this.ids.next(\"\", 36)}`\n subscriptions.insert(arn, {\n SubscriptionArn: arn,\n TopicArn: id,\n Protocol: protocol,\n Endpoint: endpoint,\n Owner: this.accountId,\n Attributes: {},\n })\n return { SubscriptionArn: arn }\n }\n if (operation === \"ConfirmSubscription\")\n return {\n SubscriptionArn:\n subscriptions.list({ where: (item) => item.TopicArn === id })[0]?.id ??\n `${id}:${this.ids.next(\"\", 36)}`,\n }\n const publish = (message: AwsInput) => {\n awsRequired(message, \"Message\")\n const messageId = this.ids.next(\"\", 36)\n this.collection(\"messages\").insert(messageId, {\n ...message,\n MessageId: messageId,\n TopicArn: id,\n Timestamp: this.now() / 1000,\n })\n return { MessageId: messageId }\n }\n if (operation === \"Publish\") return publish(input)\n if (operation === \"PublishBatch\") {\n const successful = [],\n failed = []\n for (const item of awsList(input.PublishBatchRequestEntries).map(awsRecord)) {\n try {\n successful.push({ Id: item.Id, ...publish(item) })\n } catch (error) {\n failed.push({\n Id: item.Id,\n Code: \"InvalidParameter\",\n SenderFault: true,\n Message: String(error),\n })\n }\n }\n return { Successful: successful, Failed: failed }\n }\n if (operation === \"ListTagsForResource\") return { Tags: topic.Tags ?? [] }\n if (operation === \"TagResource\" || operation === \"UntagResource\") {\n const incoming = operation === \"TagResource\" ? awsList(input.Tags).map(awsRecord) : []\n const removed =\n operation === \"UntagResource\" ? awsList(input.TagKeys) : incoming.map((item) => item.Key)\n topics.insert(id, {\n ...topic,\n Tags: [\n ...awsList(topic.Tags)\n .map(awsRecord)\n .filter((item) => !removed.includes(item.Key)),\n ...incoming,\n ],\n })\n return {}\n }\n return this.unsupported(operation)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA,+CAAC,QAAS,uBAAsB,SAAU,2BAA0B,MAAO,gCAA+B,OAAQ,mDAAkD,MAAO,8gIAA6gI,OAAQ,WAAU,aAAc,8CAA6C;;;ACArwI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAc;AACd,SAAS,mBAAmB,gBAAgB,iBAAiB,qBAAqB;AAC3E,IAAM,kBACX,OAAsD,sBAAkC;AAC1F,IAAM,cACJ,OAAO,2CAAgC,WAAW,yCAA8B;AAC3E,IAAM,gBAAgB,CAAC,YAC5B,cAAc;AAAA,EACZ,GAAG;AAAA,EACH,SAAS,QAAQ,WAAW;AAAA,EAC5B,YAAY,QAAQ,cAAc;AACpC,CAAC;;;ACPI,IAAM,WAA4B,KAAK,MAAM,i2DAAi2D;AAI94D,IAAM,eAAe,CAAC,YAAW,UAAS,cAAa,cAAa,e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ACvB,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO,EAAE,YAAY,YAAY,QAAQ,OAAO;AAAA,IAClD;AACA,QAAI,cAAc,sBAAuB,QAAO,EAAE,MAAM,MAAM,QAAQ,CAAC,EAAE;AACzE,QAAI,cAAc,iBAAiB,cAAc,iBAAiB;AAChE,YAAM,WAAW,cAAc,oBAAgB,yBAAQ,MAAM,IAAI,EAAE,IAAI,yBAAS,IAAI,CAAC;AACrF,YAAM,UACJ,cAAc,sBAAkB,yBAAQ,MAAM,OAAO,IAAI,SAAS,IAAI,CAAC,SAAS,KAAK,GAAG;AAC1F,aAAO,OAAO,IAAI;AAAA,QAChB,GAAG;AAAA,QACH,MAAM;AAAA,UACJ,OAAG,yBAAQ,MAAM,IAAI,EAClB,IAAI,yBAAS,EACb,OAAO,CAAC,SAAS,CAAC,QAAQ,SAAS,KAAK,GAAG,CAAC;AAAA,UAC/C,GAAG;AAAA,QACL;AAAA,MACF,CAAC;AACD,aAAO,CAAC;AAAA,IACV;AACA,WAAO,KAAK,YAAY,SAAS;AAAA,EACnC;AACF;",
6
+ "names": ["createRuntime", "id"]
7
+ }
package/dist/cli.js CHANGED
@@ -1,13 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- runCli,
4
- serveCommand,
5
3
  serveTarget
6
- } from "./chunk-ZA6YJK64.js";
7
- import "./chunk-VH4RZZ5G.js";
8
- import "./chunk-YQXJWQH3.js";
4
+ } from "./chunk-OE6OFGUC.js";
5
+ import "./chunk-R3ZSEUIJ.js";
9
6
 
10
7
  // src/cli.ts
8
+ import { runCli, serveCommand } from "@crvouga/mockingbird-runtime/adapter-node";
11
9
  var code = await runCli(
12
10
  {
13
11
  bin: "mockingbird-sns",
package/dist/cli.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/cli.ts"],
4
4
  "sourcesContent": ["#!/usr/bin/env node\n/// <reference types=\"node\" />\nimport { runCli, serveCommand } from \"@crvouga/mockingbird-adapter-node\"\nimport { serveTarget } from \"./server.js\"\n\nconst code = await runCli(\n {\n bin: \"mockingbird-sns\",\n description: \"stateful Amazon Simple Notification Service mock\",\n commands: { serve: serveCommand(serveTarget) },\n },\n process.argv.slice(2),\n)\nif (code !== 0) process.exitCode = code\n"],
5
- "mappings": ";;;;;;;;;;AAKA,IAAM,OAAO,MAAM;AAAA,EACjB;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,UAAU,EAAE,OAAO,aAAa,WAAW,EAAE;AAAA,EAC/C;AAAA,EACA,QAAQ,KAAK,MAAM,CAAC;AACtB;AACA,IAAI,SAAS,EAAG,SAAQ,WAAW;",
5
+ "mappings": ";;;;;;;AAEA,SAAS,QAAQ,oBAAoB;AAGrC,IAAM,OAAO,MAAM;AAAA,EACjB;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,UAAU,EAAE,OAAO,aAAa,WAAW,EAAE;AAAA,EAC/C;AAAA,EACA,QAAQ,KAAK,MAAM,CAAC;AACtB;AACA,IAAI,SAAS,EAAG,SAAQ,WAAW;",
6
6
  "names": []
7
7
  }