@algolia/client-personalization 4.14.1 → 5.0.0-alpha.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.
Files changed (42) hide show
  1. package/dist/builds/browser.d.ts +6 -0
  2. package/dist/builds/browser.d.ts.map +1 -0
  3. package/dist/builds/node.d.ts +6 -0
  4. package/dist/builds/node.d.ts.map +1 -0
  5. package/dist/client-personalization.cjs.js +270 -34
  6. package/dist/client-personalization.esm.browser.js +994 -0
  7. package/dist/client-personalization.esm.node.js +280 -0
  8. package/dist/client-personalization.umd.js +2 -0
  9. package/dist/model/clientMethodProps.d.ts +79 -0
  10. package/dist/model/clientMethodProps.d.ts.map +1 -0
  11. package/dist/model/deleteUserProfileResponse.d.ts +11 -0
  12. package/dist/model/deleteUserProfileResponse.d.ts.map +1 -0
  13. package/dist/model/errorBase.d.ts +7 -0
  14. package/dist/model/errorBase.d.ts.map +1 -0
  15. package/dist/model/eventScoring.d.ts +15 -0
  16. package/dist/model/eventScoring.d.ts.map +1 -0
  17. package/dist/model/facetScoring.d.ts +11 -0
  18. package/dist/model/facetScoring.d.ts.map +1 -0
  19. package/dist/model/getUserTokenResponse.d.ts +15 -0
  20. package/dist/model/getUserTokenResponse.d.ts.map +1 -0
  21. package/dist/model/index.d.ts +9 -0
  22. package/dist/model/index.d.ts.map +1 -0
  23. package/dist/model/personalizationStrategyParams.d.ts +17 -0
  24. package/dist/model/personalizationStrategyParams.d.ts.map +1 -0
  25. package/dist/model/setPersonalizationStrategyResponse.d.ts +7 -0
  26. package/dist/model/setPersonalizationStrategyResponse.d.ts.map +1 -0
  27. package/dist/src/personalizationClient.d.ts +105 -0
  28. package/dist/src/personalizationClient.d.ts.map +1 -0
  29. package/index.d.ts +2 -0
  30. package/index.js +1 -1
  31. package/model/clientMethodProps.ts +85 -0
  32. package/model/deleteUserProfileResponse.ts +12 -0
  33. package/model/errorBase.ts +8 -0
  34. package/model/eventScoring.ts +16 -0
  35. package/model/facetScoring.ts +12 -0
  36. package/model/getUserTokenResponse.ts +16 -0
  37. package/model/index.ts +10 -0
  38. package/model/personalizationStrategyParams.ts +19 -0
  39. package/model/setPersonalizationStrategyResponse.ts +8 -0
  40. package/package.json +25 -13
  41. package/dist/client-personalization.d.ts +0 -93
  42. package/dist/client-personalization.esm.js +0 -43
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- // eslint-disable-next-line functional/immutable-data, import/no-commonjs
1
+ // eslint-disable-next-line import/no-commonjs,import/extensions
2
2
  module.exports = require('./dist/client-personalization.cjs.js');
@@ -0,0 +1,85 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ /**
4
+ * Properties for the `del` method.
5
+ */
6
+ export type DelProps = {
7
+ /**
8
+ * The path of the API endpoint to target, anything after the /1 needs to be specified.
9
+ */
10
+ path: string;
11
+ /**
12
+ * Query parameters to be applied to the current query.
13
+ */
14
+ parameters?: Record<string, any>;
15
+ };
16
+
17
+ /**
18
+ * Properties for the `deleteUserProfile` method.
19
+ */
20
+ export type DeleteUserProfileProps = {
21
+ /**
22
+ * UserToken representing the user for which to fetch the Personalization profile.
23
+ */
24
+ userToken: string;
25
+ };
26
+
27
+ /**
28
+ * Properties for the `get` method.
29
+ */
30
+ export type GetProps = {
31
+ /**
32
+ * The path of the API endpoint to target, anything after the /1 needs to be specified.
33
+ */
34
+ path: string;
35
+ /**
36
+ * Query parameters to be applied to the current query.
37
+ */
38
+ parameters?: Record<string, any>;
39
+ };
40
+
41
+ /**
42
+ * Properties for the `getUserTokenProfile` method.
43
+ */
44
+ export type GetUserTokenProfileProps = {
45
+ /**
46
+ * UserToken representing the user for which to fetch the Personalization profile.
47
+ */
48
+ userToken: string;
49
+ };
50
+
51
+ /**
52
+ * Properties for the `post` method.
53
+ */
54
+ export type PostProps = {
55
+ /**
56
+ * The path of the API endpoint to target, anything after the /1 needs to be specified.
57
+ */
58
+ path: string;
59
+ /**
60
+ * Query parameters to be applied to the current query.
61
+ */
62
+ parameters?: Record<string, any>;
63
+ /**
64
+ * The parameters to send with the custom request.
65
+ */
66
+ body?: Record<string, any>;
67
+ };
68
+
69
+ /**
70
+ * Properties for the `put` method.
71
+ */
72
+ export type PutProps = {
73
+ /**
74
+ * The path of the API endpoint to target, anything after the /1 needs to be specified.
75
+ */
76
+ path: string;
77
+ /**
78
+ * Query parameters to be applied to the current query.
79
+ */
80
+ parameters?: Record<string, any>;
81
+ /**
82
+ * The parameters to send with the custom request.
83
+ */
84
+ body?: Record<string, any>;
85
+ };
@@ -0,0 +1,12 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type DeleteUserProfileResponse = {
4
+ /**
5
+ * UserToken representing the user for which to fetch the Personalization profile.
6
+ */
7
+ userToken: string;
8
+ /**
9
+ * A date until which the data can safely be considered as deleted for the given user. Any data received after the `deletedUntil` date will start building a new user profile.
10
+ */
11
+ deletedUntil: string;
12
+ };
@@ -0,0 +1,8 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ /**
4
+ * Error.
5
+ */
6
+ export type ErrorBase = Record<string, any> & {
7
+ message?: string;
8
+ };
@@ -0,0 +1,16 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type EventScoring = {
4
+ /**
5
+ * The score for the event.
6
+ */
7
+ score: number;
8
+ /**
9
+ * The name of the event.
10
+ */
11
+ eventName: string;
12
+ /**
13
+ * The type of the event.
14
+ */
15
+ eventType: string;
16
+ };
@@ -0,0 +1,12 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type FacetScoring = {
4
+ /**
5
+ * The score for the event.
6
+ */
7
+ score: number;
8
+ /**
9
+ * The name of the facet.
10
+ */
11
+ facetName: string;
12
+ };
@@ -0,0 +1,16 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type GetUserTokenResponse = {
4
+ /**
5
+ * UserToken representing the user for which to fetch the Personalization profile.
6
+ */
7
+ userToken: string;
8
+ /**
9
+ * Date of last event update. (ISO-8601 format).
10
+ */
11
+ lastEventAt: string;
12
+ /**
13
+ * The userToken scores.
14
+ */
15
+ scores: Record<string, any>;
16
+ };
package/model/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export * from './deleteUserProfileResponse';
4
+ export * from './errorBase';
5
+ export * from './eventScoring';
6
+ export * from './facetScoring';
7
+ export * from './getUserTokenResponse';
8
+ export * from './personalizationStrategyParams';
9
+ export * from './setPersonalizationStrategyResponse';
10
+ export * from './clientMethodProps';
@@ -0,0 +1,19 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ import type { EventScoring } from './eventScoring';
4
+ import type { FacetScoring } from './facetScoring';
5
+
6
+ export type PersonalizationStrategyParams = {
7
+ /**
8
+ * Scores associated with the events.
9
+ */
10
+ eventScoring: EventScoring[];
11
+ /**
12
+ * Scores associated with the facets.
13
+ */
14
+ facetScoring: FacetScoring[];
15
+ /**
16
+ * The impact that personalization has on search results: a number between 0 (personalization disabled) and 100 (personalization fully enabled).
17
+ */
18
+ personalizationImpact: number;
19
+ };
@@ -0,0 +1,8 @@
1
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2
+
3
+ export type SetPersonalizationStrategyResponse = {
4
+ /**
5
+ * A message confirming the strategy update.
6
+ */
7
+ message: string;
8
+ };
package/package.json CHANGED
@@ -1,23 +1,35 @@
1
1
  {
2
2
  "name": "@algolia/client-personalization",
3
- "version": "4.14.1",
4
- "private": false,
5
- "repository": {
6
- "type": "git",
7
- "url": "git://github.com/algolia/algoliasearch-client-javascript.git"
8
- },
3
+ "version": "5.0.0-alpha.2",
4
+ "description": "JavaScript client for client-personalization",
5
+ "repository": "algolia/algoliasearch-client-javascript",
9
6
  "license": "MIT",
10
- "sideEffects": false,
7
+ "author": "Algolia",
11
8
  "main": "index.js",
12
- "module": "dist/client-personalization.esm.js",
13
- "types": "dist/client-personalization.d.ts",
9
+ "jsdelivr": "dist/client-personalization.umd.js",
10
+ "unpkg": "dist/client-personalization.umd.js",
11
+ "module": "dist/client-personalization.esm.node.js",
12
+ "browser": "dist/client-personalization.umd.js",
13
+ "types": "index.d.ts",
14
14
  "files": [
15
+ "dist",
16
+ "model",
15
17
  "index.js",
16
- "dist"
18
+ "index.d.ts"
17
19
  ],
20
+ "scripts": {
21
+ "clean": "rm -rf ./dist"
22
+ },
18
23
  "dependencies": {
19
- "@algolia/client-common": "4.14.1",
20
- "@algolia/requester-common": "4.14.1",
21
- "@algolia/transporter": "4.14.1"
24
+ "@algolia/client-common": "5.0.0-alpha.2",
25
+ "@algolia/requester-browser-xhr": "5.0.0-alpha.2",
26
+ "@algolia/requester-node-http": "5.0.0-alpha.2"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "16.11.45",
30
+ "typescript": "4.7.4"
31
+ },
32
+ "engines": {
33
+ "node": ">= 14.0.0"
22
34
  }
23
35
  }
@@ -1,93 +0,0 @@
1
- import { ClientTransporterOptions } from '@algolia/client-common';
2
- import { CreateClient } from '@algolia/client-common';
3
- import { RequestOptions } from '@algolia/transporter';
4
- import { Transporter } from '@algolia/transporter';
5
-
6
- export declare const createPersonalizationClient: CreateClient<PersonalizationClient, PersonalizationClientOptions & ClientTransporterOptions>;
7
-
8
- export declare const getPersonalizationStrategy: (base: PersonalizationClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<GetPersonalizationStrategyResponse>>;
9
-
10
- export declare type GetPersonalizationStrategyResponse = {
11
- /**
12
- * Events scoring
13
- */
14
- eventsScoring: Array<{
15
- eventName: string;
16
- eventType: string;
17
- score: number;
18
- }>;
19
- /**
20
- * Facets scoring
21
- */
22
- facetsScoring: Array<{
23
- facetName: string;
24
- score: number;
25
- }>;
26
- /**
27
- * Personalization impact
28
- */
29
- personalizationImpact: number;
30
- };
31
-
32
- export declare type PersonalizationClient = {
33
- /**
34
- * The application id.
35
- */
36
- readonly appId: string;
37
- /**
38
- * The underlying transporter.
39
- */
40
- readonly transporter: Transporter;
41
- };
42
-
43
- export declare type PersonalizationClientOptions = {
44
- /**
45
- * The application id.
46
- */
47
- readonly appId: string;
48
- /**
49
- * The api key.
50
- */
51
- readonly apiKey: string;
52
- /**
53
- * The prefered region.
54
- */
55
- readonly region?: string;
56
- };
57
-
58
- export declare type PersonalizationStrategy = {
59
- /**
60
- * Events scoring
61
- */
62
- readonly eventsScoring: ReadonlyArray<{
63
- readonly eventName: string;
64
- readonly eventType: string;
65
- readonly score: number;
66
- }>;
67
- /**
68
- * Facets scoring
69
- */
70
- readonly facetsScoring: ReadonlyArray<{
71
- readonly facetName: string;
72
- readonly score: number;
73
- }>;
74
- /**
75
- * Personalization impact
76
- */
77
- readonly personalizationImpact: number;
78
- };
79
-
80
- export declare const setPersonalizationStrategy: (base: PersonalizationClient) => (personalizationStrategy: PersonalizationStrategy, requestOptions?: RequestOptions | undefined) => Readonly<Promise<SetPersonalizationStrategyResponse>>;
81
-
82
- export declare type SetPersonalizationStrategyResponse = {
83
- /**
84
- * The status code.
85
- */
86
- status?: number;
87
- /**
88
- * The message.
89
- */
90
- message: string;
91
- };
92
-
93
- export { }
@@ -1,43 +0,0 @@
1
- import { createAuth, AuthMode, addMethods } from '@algolia/client-common';
2
- import { createTransporter } from '@algolia/transporter';
3
- import { MethodEnum } from '@algolia/requester-common';
4
-
5
- const createPersonalizationClient = options => {
6
- const region = options.region || 'us';
7
- const auth = createAuth(AuthMode.WithinHeaders, options.appId, options.apiKey);
8
- const transporter = createTransporter({
9
- hosts: [{ url: `personalization.${region}.algolia.com` }],
10
- ...options,
11
- headers: {
12
- ...auth.headers(),
13
- ...{ 'content-type': 'application/json' },
14
- ...options.headers,
15
- },
16
- queryParameters: {
17
- ...auth.queryParameters(),
18
- ...options.queryParameters,
19
- },
20
- });
21
- return addMethods({ appId: options.appId, transporter }, options.methods);
22
- };
23
-
24
- const getPersonalizationStrategy = (base) => {
25
- return (requestOptions) => {
26
- return base.transporter.read({
27
- method: MethodEnum.Get,
28
- path: '1/strategies/personalization',
29
- }, requestOptions);
30
- };
31
- };
32
-
33
- const setPersonalizationStrategy = (base) => {
34
- return (personalizationStrategy, requestOptions) => {
35
- return base.transporter.write({
36
- method: MethodEnum.Post,
37
- path: '1/strategies/personalization',
38
- data: personalizationStrategy,
39
- }, requestOptions);
40
- };
41
- };
42
-
43
- export { createPersonalizationClient, getPersonalizationStrategy, setPersonalizationStrategy };