@memberjunction/actions-apollo 6.1.0-edge.4 → 6.1.0-edge.5

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 (46) hide show
  1. package/README.md +79 -0
  2. package/dist/__tests__/apollo-lists.test.d.ts +2 -0
  3. package/dist/__tests__/apollo-lists.test.d.ts.map +1 -0
  4. package/dist/__tests__/apollo-lists.test.js +957 -0
  5. package/dist/__tests__/apollo-lists.test.js.map +1 -0
  6. package/dist/config.d.ts +10 -0
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +10 -0
  9. package/dist/config.js.map +1 -1
  10. package/dist/generic/apollo-lists.types.d.ts +246 -0
  11. package/dist/generic/apollo-lists.types.d.ts.map +1 -0
  12. package/dist/generic/apollo-lists.types.js +42 -0
  13. package/dist/generic/apollo-lists.types.js.map +1 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +11 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/lists/ApolloListActions.d.ts +49 -0
  19. package/dist/lists/ApolloListActions.d.ts.map +1 -0
  20. package/dist/lists/ApolloListActions.js +135 -0
  21. package/dist/lists/ApolloListActions.js.map +1 -0
  22. package/dist/lists/ApolloMoveActions.d.ts +33 -0
  23. package/dist/lists/ApolloMoveActions.d.ts.map +1 -0
  24. package/dist/lists/ApolloMoveActions.js +272 -0
  25. package/dist/lists/ApolloMoveActions.js.map +1 -0
  26. package/dist/lists/ApolloRESTBaseAction.d.ts +49 -0
  27. package/dist/lists/ApolloRESTBaseAction.d.ts.map +1 -0
  28. package/dist/lists/ApolloRESTBaseAction.js +70 -0
  29. package/dist/lists/ApolloRESTBaseAction.js.map +1 -0
  30. package/dist/lists/ApolloRESTClient.d.ts +136 -0
  31. package/dist/lists/ApolloRESTClient.d.ts.map +1 -0
  32. package/dist/lists/ApolloRESTClient.js +561 -0
  33. package/dist/lists/ApolloRESTClient.js.map +1 -0
  34. package/dist/lists/ApolloSearchActions.d.ts +64 -0
  35. package/dist/lists/ApolloSearchActions.d.ts.map +1 -0
  36. package/dist/lists/ApolloSearchActions.js +239 -0
  37. package/dist/lists/ApolloSearchActions.js.map +1 -0
  38. package/dist/lists/credentials.d.ts +57 -0
  39. package/dist/lists/credentials.d.ts.map +1 -0
  40. package/dist/lists/credentials.js +161 -0
  41. package/dist/lists/credentials.js.map +1 -0
  42. package/dist/lists/params.d.ts +61 -0
  43. package/dist/lists/params.d.ts.map +1 -0
  44. package/dist/lists/params.js +113 -0
  45. package/dist/lists/params.js.map +1 -0
  46. package/package.json +8 -7
@@ -0,0 +1,136 @@
1
+ import type { ApolloAccount, ApolloAccountSearchFilter, ApolloAccountsPage, ApolloContact, ApolloContactSearchFilter, ApolloContactsPage, ApolloLabel, ApolloMoveResult, ApolloPagingOptions, ApolloPeoplePage, ApolloPeopleSearchFilter, IApolloRESTClient } from '../generic/apollo-lists.types.js';
2
+ /** Options for {@link ApolloRESTClient}. */
3
+ export interface ApolloRESTClientOptions {
4
+ /**
5
+ * Injected fetch, for tests. Tests must never reach api.apollo.io — a live
6
+ * call would consume real credits and mutate a real account's lists.
7
+ */
8
+ fetchImpl?: typeof fetch;
9
+ }
10
+ /**
11
+ * Apollo.io list/search client. See the module doc, and the quirk list on
12
+ * `apollo-lists.types.ts`, for the behaviours it encodes.
13
+ */
14
+ export declare class ApolloRESTClient implements IApolloRESTClient {
15
+ private readonly apiKey;
16
+ private readonly fetchImpl;
17
+ /**
18
+ * The label id↔name maps, built on first use and cached for the instance
19
+ * lifetime (quirk #5). One labels call per client, shared by every search and
20
+ * move. No TTL: a single drain or move operation uses one instance, and
21
+ * labels do not churn mid-operation. Construct a new client to see label
22
+ * changes made since.
23
+ */
24
+ private labelMaps;
25
+ constructor(apiKey: string, options?: ApolloRESTClientOptions);
26
+ /**
27
+ * Issue one request and return the parsed body. A non-2xx throws with the
28
+ * method, path, status and whatever detail Apollo supplied; a 403 on a
29
+ * master-key operation throws the master-key explanation instead (quirk #4).
30
+ * Nothing is swallowed — a body that will not parse still surfaces its text.
31
+ */
32
+ private request;
33
+ /**
34
+ * Every label, account lists and contact lists alike. Master key required.
35
+ * Apollo returns either a bare array or a `{ labels: [...] }` envelope
36
+ * depending on the account; both are accepted.
37
+ */
38
+ listLabels(): Promise<ApolloLabel[]>;
39
+ /**
40
+ * Create a label. Master key required.
41
+ *
42
+ * `modality` is not optional to Apollo despite reading like it should be:
43
+ * posting without it returns HTTP 422 "Please enter a non-empty modality!".
44
+ * It defaults to 'contacts' here because a people list is the common case.
45
+ *
46
+ * The create response shape is not pinned in Apollo's docs, so a bare label
47
+ * object, a `{ label: {...} }` envelope and a `{ labels: [...] }` envelope
48
+ * are all accepted — mirroring how {@link listLabels} tolerates two read
49
+ * shapes. A shape none of those match throws rather than returning a label
50
+ * with an empty id, which would then be written into a membership array.
51
+ */
52
+ createLabel(name: string, modality?: 'contacts' | 'accounts'): Promise<ApolloLabel>;
53
+ /**
54
+ * Resolve a label by exact name, case-insensitive; null when nothing matches.
55
+ * This is how a human-supplied list name becomes the id a search filter needs.
56
+ */
57
+ findLabelByName(name: string): Promise<ApolloLabel | null>;
58
+ /**
59
+ * Build (once per instance) the id↔name maps that resolve search-response
60
+ * `label_ids` into names (quirk #5). When two labels share a name — rare — the
61
+ * last one wins in `nameToId`.
62
+ */
63
+ private getLabelMaps;
64
+ /** One aggregated warning for label ids that did not resolve to a name (quirk #5). */
65
+ private warnUnresolvedLabels;
66
+ /**
67
+ * One page of saved accounts. Paging defaults to page 1 — when draining a
68
+ * list, never advance (quirk #3).
69
+ */
70
+ searchAccounts(filter: ApolloAccountSearchFilter, paging?: ApolloPagingOptions): Promise<ApolloAccountsPage>;
71
+ /** One page of saved contacts. Same drain-page-1 default as {@link searchAccounts}. */
72
+ searchContacts(filter: ApolloContactSearchFilter, paging?: ApolloPagingOptions): Promise<ApolloContactsPage>;
73
+ /**
74
+ * One page of prospecting people — net-new, not your saved contacts. Apollo
75
+ * does not return emails or phones here by design.
76
+ *
77
+ * Unlike the two searches above, this one does not need the label maps: the
78
+ * prospecting response carries no memberships, so fetching them would be a
79
+ * wasted master-key call on a read a scoped key can otherwise serve.
80
+ */
81
+ searchPeople(filter: ApolloPeopleSearchFilter, paging?: ApolloPagingOptions): Promise<ApolloPeoplePage>;
82
+ /**
83
+ * Replace one account's label set with `labelNames` — which must be the
84
+ * COMPLETE intended set, because Apollo overwrites wholesale (quirk #1).
85
+ * Master key required.
86
+ */
87
+ private updateAccountLabels;
88
+ /** The same for one contact. Identical full-replace and master-key semantics. */
89
+ private updateContactLabels;
90
+ /**
91
+ * Re-read one account's current labels for the verify pass (quirk #2), by
92
+ * searching the destination list and matching on id. Null when the record is
93
+ * not on that page, which is not the same as "the remove worked" — hence
94
+ * `possiblyStuck` stays null rather than becoming false.
95
+ */
96
+ private readAccountLabels;
97
+ private readContactLabels;
98
+ /**
99
+ * The ADD phase's label set: current ∪ {toList}. Idempotent — adding a label
100
+ * the record already carries is a set no-op, so re-running a partial move
101
+ * does not duplicate anything.
102
+ */
103
+ private addPhaseLabels;
104
+ /**
105
+ * The REMOVE phase's label set: (current ∪ {toList}) \ {fromList}.
106
+ *
107
+ * It is computed from the post-add state rather than from `current` so that
108
+ * the destination label survives the second write. Deriving it from `current`
109
+ * alone would add the record to the destination and then immediately take it
110
+ * back out.
111
+ */
112
+ private removePhaseLabels;
113
+ /**
114
+ * The move engine, shared by accounts and contacts through the injected
115
+ * update/read closures so the label-preservation math and the stuck detection
116
+ * exist in exactly one place.
117
+ */
118
+ private moveRecords;
119
+ /**
120
+ * Move accounts between lists. The supplied accounts must carry current
121
+ * `labelNames` from a fresh {@link searchAccounts} read — this method writes
122
+ * whatever it is given as the intended set, so stale labels here mean real
123
+ * memberships silently disappear.
124
+ *
125
+ * With `verify`, the destination list is re-read after each remove to flag
126
+ * silent-fail records. Never deletes, never auto-retries.
127
+ */
128
+ moveAccounts(accounts: ApolloAccount[], fromList: string, toList: string, options?: {
129
+ verify?: boolean;
130
+ }): Promise<ApolloMoveResult>;
131
+ /** Move contacts between lists. Same two-step and verify semantics as accounts. */
132
+ moveContacts(contacts: ApolloContact[], fromList: string, toList: string, options?: {
133
+ verify?: boolean;
134
+ }): Promise<ApolloMoveResult>;
135
+ }
136
+ //# sourceMappingURL=ApolloRESTClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloRESTClient.d.ts","sourceRoot":"","sources":["../../src/lists/ApolloRESTClient.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EACR,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,WAAW,EAEX,gBAAgB,EAEhB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EAExB,iBAAiB,EACpB,MAAM,kCAAkC,CAAC;AAO1C,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC5B;AA+GD;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,CAA0B;gBAE/B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB;IAW7D;;;;;OAKG;YACW,OAAO;IAgErB;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAiBjD;;;;;;;;;;;;OAYG;IACU,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,UAAU,GAAG,UAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IAoC5G;;;OAGG;IACU,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IASvE;;;;OAIG;YACW,YAAY;IAmB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