ad2app-lib 1.39.0 → 1.40.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.
@@ -62,3 +62,16 @@ export declare const MAX_UPLOAD_BYTES: number;
62
62
  export declare const PUBLISH_LIMITS: Record<PublishPlatform, PlatformPublishLimits>;
63
63
  /** All publish platforms, canonical order (mirrors PUBLISH_LIMITS key order). */
64
64
  export declare const ALL_PUBLISH_PLATFORMS: PublishPlatform[];
65
+ /**
66
+ * Platforms where an already-PUBLISHED post can be deleted through our vendor
67
+ * (ad2app-backend#303). Mirrors the `platform` enum of Zernio's
68
+ * POST /v1/posts/{postId}/unpublish (openapi 1.0.4), intersected with ours.
69
+ * Instagram and TikTok are absent because the vendor does not support them:
70
+ * a post published there stays live until the creator deletes it in that app.
71
+ *
72
+ * An allowlist on purpose: a platform nobody has checked reads as "stays live",
73
+ * which is the claim that cannot mislead a creator into thinking a post is gone.
74
+ */
75
+ export declare const UNPUBLISHABLE_PLATFORMS: readonly PublishPlatform[];
76
+ /** Whether a published post on `platform` can be deleted from the platform by ad2app. */
77
+ export declare function canUnpublish(platform: string): boolean;
@@ -51,7 +51,8 @@
51
51
  * cap — MAX_UPLOAD_BYTES is).
52
52
  */
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.ALL_PUBLISH_PLATFORMS = exports.PUBLISH_LIMITS = exports.MAX_UPLOAD_BYTES = void 0;
54
+ exports.UNPUBLISHABLE_PLATFORMS = exports.ALL_PUBLISH_PLATFORMS = exports.PUBLISH_LIMITS = exports.MAX_UPLOAD_BYTES = void 0;
55
+ exports.canUnpublish = canUnpublish;
55
56
  /**
56
57
  * The universal media-upload byte cap ad2app enforces on every publish,
57
58
  * regardless of destination platform. This is ad2app's own operational
@@ -146,3 +147,27 @@ exports.PUBLISH_LIMITS = {
146
147
  };
147
148
  /** All publish platforms, canonical order (mirrors PUBLISH_LIMITS key order). */
148
149
  exports.ALL_PUBLISH_PLATFORMS = Object.keys(exports.PUBLISH_LIMITS);
150
+ /**
151
+ * Platforms where an already-PUBLISHED post can be deleted through our vendor
152
+ * (ad2app-backend#303). Mirrors the `platform` enum of Zernio's
153
+ * POST /v1/posts/{postId}/unpublish (openapi 1.0.4), intersected with ours.
154
+ * Instagram and TikTok are absent because the vendor does not support them:
155
+ * a post published there stays live until the creator deletes it in that app.
156
+ *
157
+ * An allowlist on purpose: a platform nobody has checked reads as "stays live",
158
+ * which is the claim that cannot mislead a creator into thinking a post is gone.
159
+ */
160
+ exports.UNPUBLISHABLE_PLATFORMS = [
161
+ 'twitter',
162
+ 'linkedin',
163
+ 'facebook',
164
+ 'youtube',
165
+ 'threads',
166
+ 'reddit',
167
+ 'pinterest',
168
+ 'bluesky',
169
+ ];
170
+ /** Whether a published post on `platform` can be deleted from the platform by ad2app. */
171
+ function canUnpublish(platform) {
172
+ return exports.UNPUBLISHABLE_PLATFORMS.includes(platform);
173
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ad2app-lib",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "commonjs",
@@ -9,7 +9,13 @@
9
9
  import assert from 'node:assert/strict';
10
10
  import { test } from 'node:test';
11
11
 
12
- import { ALL_PUBLISH_PLATFORMS, MAX_UPLOAD_BYTES, PUBLISH_LIMITS } from './index';
12
+ import {
13
+ ALL_PUBLISH_PLATFORMS,
14
+ canUnpublish,
15
+ MAX_UPLOAD_BYTES,
16
+ PUBLISH_LIMITS,
17
+ UNPUBLISHABLE_PLATFORMS,
18
+ } from './index';
13
19
  import type { PublishPlatform } from './types';
14
20
 
15
21
  const EXPECTED_PLATFORMS: PublishPlatform[] = [
@@ -114,3 +120,22 @@ test('PlatformPublishLimits contract does not carry per-platform byte-size field
114
120
  ].sort(),
115
121
  );
116
122
  });
123
+
124
+ test('canUnpublish: Instagram and TikTok published posts cannot be deleted by ad2app (backend#303)', () => {
125
+ assert.equal(canUnpublish('instagram'), false);
126
+ assert.equal(canUnpublish('tiktok'), false);
127
+ for (const platform of ALL_PUBLISH_PLATFORMS.filter((p) => p !== 'instagram' && p !== 'tiktok')) {
128
+ assert.equal(canUnpublish(platform), true, `${platform} should be unpublishable`);
129
+ }
130
+ });
131
+
132
+ test('canUnpublish: an unknown platform reads as not unpublishable', () => {
133
+ assert.equal(canUnpublish('snapchat'), false);
134
+ assert.equal(canUnpublish(''), false);
135
+ });
136
+
137
+ test('UNPUBLISHABLE_PLATFORMS only names platforms ad2app publishes to', () => {
138
+ for (const platform of UNPUBLISHABLE_PLATFORMS) {
139
+ assert.ok(platform in PUBLISH_LIMITS, `${platform} is not a publish platform`);
140
+ }
141
+ });
@@ -152,3 +152,29 @@ export const PUBLISH_LIMITS: Record<PublishPlatform, PlatformPublishLimits> = {
152
152
  export const ALL_PUBLISH_PLATFORMS: PublishPlatform[] = Object.keys(
153
153
  PUBLISH_LIMITS,
154
154
  ) as PublishPlatform[];
155
+
156
+ /**
157
+ * Platforms where an already-PUBLISHED post can be deleted through our vendor
158
+ * (ad2app-backend#303). Mirrors the `platform` enum of Zernio's
159
+ * POST /v1/posts/{postId}/unpublish (openapi 1.0.4), intersected with ours.
160
+ * Instagram and TikTok are absent because the vendor does not support them:
161
+ * a post published there stays live until the creator deletes it in that app.
162
+ *
163
+ * An allowlist on purpose: a platform nobody has checked reads as "stays live",
164
+ * which is the claim that cannot mislead a creator into thinking a post is gone.
165
+ */
166
+ export const UNPUBLISHABLE_PLATFORMS: readonly PublishPlatform[] = [
167
+ 'twitter',
168
+ 'linkedin',
169
+ 'facebook',
170
+ 'youtube',
171
+ 'threads',
172
+ 'reddit',
173
+ 'pinterest',
174
+ 'bluesky',
175
+ ];
176
+
177
+ /** Whether a published post on `platform` can be deleted from the platform by ad2app. */
178
+ export function canUnpublish(platform: string): boolean {
179
+ return (UNPUBLISHABLE_PLATFORMS as readonly string[]).includes(platform);
180
+ }