@manta-eu/lib 0.1.0 → 0.1.2

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/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @manta-eu/lib
2
+
3
+ Small TypeScript helpers shared across the Manta packages — plain functions and types, no
4
+ framework and no service calls.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ pnpm add @manta-eu/lib
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ Each module is its own subpath, so you import only what you use:
15
+
16
+ ```typescript
17
+ import { arrayWrap } from "@manta-eu/lib/array";
18
+ import { humanBytes, humanDuration } from "@manta-eu/lib/humanize";
19
+ ```
20
+
21
+ Modules include `array`, `date`, `number`, `color`, `file`, `enum`, `humanize`, `present`,
22
+ `countries` and `ad-platform-links`. `present` carries `isPresent`, which is how this repo checks for
23
+ a value rather than testing `.length` or truthiness.
24
+
25
+ This package exists so `@manta-eu/client`, `@manta-eu/react` and `@manta-eu/rdf-lib` share one copy
26
+ of these helpers rather than three. It is published because those packages depend on it; most
27
+ consumers reach it transitively rather than naming it directly.
28
+
29
+ ## License
30
+
31
+ MIT
@@ -1,7 +1,8 @@
1
1
  export type MetaAdsManagerCampaignLinkOptions = {
2
2
  adAccountExternalId: string;
3
3
  campaignExternalId: string[];
4
- marketerPartnerBusinessId: boolean;
4
+ /** Meta business the ad account is shared with; omit when the link is not going through one. */
5
+ partnerBusinessId?: string;
5
6
  };
6
7
  export declare function generateMetaAdsManagerCampaignLink(args: MetaAdsManagerCampaignLinkOptions): string;
7
8
  //# sourceMappingURL=ad-platform-links.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ad-platform-links.d.ts","sourceRoot":"","sources":["../src/ad-platform-links.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iCAAiC,GAAG;IAC9C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,iCAAiC,UAYzF"}
1
+ {"version":3,"file":"ad-platform-links.d.ts","sourceRoot":"","sources":["../src/ad-platform-links.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iCAAiC,GAAG;IAC9C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,iCAAiC,UAYzF"}
@@ -1,12 +1,12 @@
1
1
  export function generateMetaAdsManagerCampaignLink(args) {
2
- const { adAccountExternalId, campaignExternalId, marketerPartnerBusinessId } = args;
2
+ const { adAccountExternalId, campaignExternalId, partnerBusinessId } = args;
3
3
  const recordSeparator = String.fromCharCode(0x1e);
4
4
  const campaignIds = campaignExternalId.map((id) => `"${id}"`).join(",");
5
5
  const filterSet = `SEARCH_BY_CAMPAIGN_GROUP_IDS-STRING_SET${recordSeparator}ANY${recordSeparator}[${campaignIds}]`;
6
6
  const url = new URL("https://adsmanager.facebook.com/adsmanager/manage/campaigns");
7
7
  url.searchParams.set("act", adAccountExternalId);
8
- if (marketerPartnerBusinessId) {
9
- url.searchParams.set("business_id", "845646597259963");
8
+ if (partnerBusinessId) {
9
+ url.searchParams.set("business_id", partnerBusinessId);
10
10
  }
11
11
  url.searchParams.set("filter_set", filterSet);
12
12
  return url.toString();
package/dist/set.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare function boundedSet<T>(limit: number): Set<T>;
1
2
  export declare function addAll<T>(set: Set<T>, items: Array<T>): void;
2
3
  export declare function addAll<T>(set: Set<T>, other: Set<T>): void;
3
4
  //# sourceMappingURL=set.d.ts.map
package/dist/set.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../src/set.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAC9D,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../src/set.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAcnD;AAOD,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAC9D,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC"}
package/dist/set.js CHANGED
@@ -1,3 +1,23 @@
1
+ // A Set that removes its oldest member to make room when it is full. Only its add method changes.
2
+ // A copy such as `new Set(bounded)` keeps the members but not the limit.
3
+ export function boundedSet(limit) {
4
+ if (!Number.isInteger(limit) || limit < 1) {
5
+ throw new RangeError(`A bounded set needs a whole limit of 1 or more, but it got ${limit}.`);
6
+ }
7
+ const set = new Set();
8
+ const nativeAdd = Set.prototype.add.bind(set);
9
+ set.add = (value) => {
10
+ if (!set.has(value) && set.size >= limit)
11
+ removeOldest(set);
12
+ return nativeAdd(value);
13
+ };
14
+ return set;
15
+ }
16
+ function removeOldest(set) {
17
+ const oldest = set.values().next();
18
+ if (!oldest.done)
19
+ set.delete(oldest.value);
20
+ }
1
21
  export function addAll(set, items) {
2
22
  if (Array.isArray(items)) {
3
23
  items.forEach((item) => set.add(item));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manta-eu/lib",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Pure TypeScript helpers shared across the Manta packages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,21 +21,13 @@
21
21
  "ramda": "^0.32.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@tanstack/react-query": "^5.100.10",
25
- "@types/node": "^20.0.0",
26
24
  "@types/pluralize": "^0.0.33",
27
25
  "@types/ramda": "^0.31.1",
28
- "@types/react": "^19.2.7",
29
- "@typescript-eslint/eslint-plugin": "^8.0.0",
30
- "@typescript-eslint/parser": "^8.0.0",
31
- "@vitest/coverage-v8": "^3.2.4",
32
26
  "eslint": "^9.0.0",
33
27
  "prettier": "^3.6.2",
34
- "react": "^19.2.3",
35
- "sonner": "^1.7.4",
28
+ "rimraf": "^6.1.3",
36
29
  "tsc-alias": "^1.9.5",
37
30
  "typescript": "^5.0.0",
38
- "usehooks-ts": "^3.1.1",
39
31
  "vitest": "^3.0.0",
40
32
  "@manta-eu/eslint-config": "0.1.0"
41
33
  },
@@ -59,8 +51,8 @@
59
51
  "access": "public"
60
52
  },
61
53
  "scripts": {
62
- "build": "tsc --project tsconfig.build.json && tsc-alias --project tsconfig.build.json --resolve-full-paths",
63
- "build:lib": "tsc --project tsconfig.build.json",
54
+ "build": "rimraf dist && tsc --project tsconfig.build.json && tsc-alias --project tsconfig.build.json --resolve-full-paths",
55
+ "build:lib": "rimraf dist && tsc --project tsconfig.build.json",
64
56
  "test": "vitest --run",
65
57
  "test:watch": "vitest --watch",
66
58
  "check": "vitest --run",