@linkforty/mobile-sdk-react-native 1.1.0 → 1.1.1
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 +9 -0
- package/dist/LinkFortySDK.d.ts +18 -1
- package/dist/LinkFortySDK.d.ts.map +1 -1
- package/dist/LinkFortySDK.js +56 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +36 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/LinkFortySDK.ts +69 -0
- package/src/index.ts +2 -0
- package/src/types.ts +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.1.1] - 2026-02-12
|
|
11
|
+
### Added
|
|
12
|
+
- `createLink()` method for creating short links programmatically from mobile apps via the LinkForty API (`POST /api/links`)
|
|
13
|
+
- `CreateLinkOptions` type — accepts `templateId`, `templateSlug`, optional `deepLinkParameters`, `title`, `description`, `customCode`, and `utmParameters`
|
|
14
|
+
- `CreateLinkResult` type — returns `url` (full shareable URL), `shortCode`, and `linkId`
|
|
15
|
+
- Exported `CreateLinkOptions` and `CreateLinkResult` types from package entry point
|
|
16
|
+
|
|
8
17
|
## [1.1.0] - 2026-02-11
|
|
9
18
|
|
|
10
19
|
### Added
|
package/dist/LinkFortySDK.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LinkFortySDK - Main SDK class for LinkForty deep linking and attribution
|
|
3
3
|
*/
|
|
4
|
-
import type { LinkFortyConfig, DeepLinkData, DeferredDeepLinkCallback, DeepLinkCallback } from './types';
|
|
4
|
+
import type { LinkFortyConfig, DeepLinkData, DeferredDeepLinkCallback, DeepLinkCallback, CreateLinkOptions, CreateLinkResult } from './types';
|
|
5
5
|
export declare class LinkFortySDK {
|
|
6
6
|
private config;
|
|
7
7
|
private deepLinkHandler;
|
|
@@ -30,6 +30,23 @@ export declare class LinkFortySDK {
|
|
|
30
30
|
* Track in-app event
|
|
31
31
|
*/
|
|
32
32
|
trackEvent(name: string, properties?: Record<string, any>): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new short link via the LinkForty API.
|
|
35
|
+
*
|
|
36
|
+
* Requires an API key to be configured in the SDK init options.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const result = await LinkFortySDK.createLink({
|
|
41
|
+
* templateId: 'uuid-of-template',
|
|
42
|
+
* templateSlug: 'ToQs',
|
|
43
|
+
* deepLinkParameters: { route: 'VIDEO_VIEWER', id: 'video-uuid' },
|
|
44
|
+
* title: 'My Video',
|
|
45
|
+
* });
|
|
46
|
+
* // result.url → 'https://go.example.com/ToQs/abc123'
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
createLink(options: CreateLinkOptions): Promise<CreateLinkResult>;
|
|
33
50
|
/**
|
|
34
51
|
* Get install ID
|
|
35
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkFortySDK.d.ts","sourceRoot":"","sources":["../src/LinkFortySDK.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EACV,eAAe,EAEf,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAQjB,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,wBAAwB,CAAyC;IACzE,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,WAAW,CAAkB;IAErC;;OAEG;IACG,IAAI,C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QAAQ,EAAE,wBAAwB,GAAG,IAAI;IAW5D;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAwB5C;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC/E;;;;;;;;;;;;;;;OAeG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmDvE;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa5C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAchC;;OAEG;YACW,aAAa;IAW3B;;OAEG;YACW,aAAa;IA+F3B;;OAEG;YACW,eAAe;IAI7B;;OAEG;YACW,UAAU;CA+BzB;;AAGD,wBAAkC"}
|
package/dist/LinkFortySDK.js
CHANGED
|
@@ -123,6 +123,62 @@ export class LinkFortySDK {
|
|
|
123
123
|
console.error('[LinkForty] Failed to track event:', error);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Create a new short link via the LinkForty API.
|
|
128
|
+
*
|
|
129
|
+
* Requires an API key to be configured in the SDK init options.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const result = await LinkFortySDK.createLink({
|
|
134
|
+
* templateId: 'uuid-of-template',
|
|
135
|
+
* templateSlug: 'ToQs',
|
|
136
|
+
* deepLinkParameters: { route: 'VIDEO_VIEWER', id: 'video-uuid' },
|
|
137
|
+
* title: 'My Video',
|
|
138
|
+
* });
|
|
139
|
+
* // result.url → 'https://go.example.com/ToQs/abc123'
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
async createLink(options) {
|
|
143
|
+
if (!this.config) {
|
|
144
|
+
throw new Error('SDK not initialized. Call init() first.');
|
|
145
|
+
}
|
|
146
|
+
if (!this.config.apiKey) {
|
|
147
|
+
throw new Error('API key required to create links. Pass apiKey in init().');
|
|
148
|
+
}
|
|
149
|
+
const body = {
|
|
150
|
+
templateId: options.templateId,
|
|
151
|
+
};
|
|
152
|
+
if (options.deepLinkParameters) {
|
|
153
|
+
body.deepLinkParameters = options.deepLinkParameters;
|
|
154
|
+
}
|
|
155
|
+
if (options.title) {
|
|
156
|
+
body.title = options.title;
|
|
157
|
+
}
|
|
158
|
+
if (options.description) {
|
|
159
|
+
body.description = options.description;
|
|
160
|
+
}
|
|
161
|
+
if (options.customCode) {
|
|
162
|
+
body.customCode = options.customCode;
|
|
163
|
+
}
|
|
164
|
+
if (options.utmParameters) {
|
|
165
|
+
body.utmParameters = options.utmParameters;
|
|
166
|
+
}
|
|
167
|
+
const response = await this.apiRequest('/api/links', {
|
|
168
|
+
method: 'POST',
|
|
169
|
+
body: JSON.stringify(body),
|
|
170
|
+
});
|
|
171
|
+
const shortCode = response.short_code;
|
|
172
|
+
const url = `${this.config.baseUrl}/${options.templateSlug}/${shortCode}`;
|
|
173
|
+
if (this.config.debug) {
|
|
174
|
+
console.log('[LinkForty] Created link:', url);
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
url,
|
|
178
|
+
shortCode,
|
|
179
|
+
linkId: response.id,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
126
182
|
/**
|
|
127
183
|
* Get install ID
|
|
128
184
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export { default } from './LinkFortySDK';
|
|
|
9
9
|
export { LinkFortySDK } from './LinkFortySDK';
|
|
10
10
|
export { FingerprintCollector } from './FingerprintCollector';
|
|
11
11
|
export { DeepLinkHandler } from './DeepLinkHandler';
|
|
12
|
-
export type { LinkFortyConfig, DeviceFingerprint, DeepLinkData, InstallAttributionResponse, EventData, DeferredDeepLinkCallback, DeepLinkCallback, ResolveFunction, } from './types';
|
|
12
|
+
export type { LinkFortyConfig, DeviceFingerprint, DeepLinkData, InstallAttributionResponse, EventData, DeferredDeepLinkCallback, DeepLinkCallback, ResolveFunction, CreateLinkOptions, CreateLinkResult, } from './types';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,SAAS,EACT,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,SAAS,EACT,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -113,4 +113,40 @@ export type DeepLinkCallback = (url: string, deepLinkData: DeepLinkData | null)
|
|
|
113
113
|
* before the server can process the redirect.
|
|
114
114
|
*/
|
|
115
115
|
export type ResolveFunction = (path: string) => Promise<DeepLinkData | null>;
|
|
116
|
+
/**
|
|
117
|
+
* Options for creating a new short link via the LinkForty API
|
|
118
|
+
*/
|
|
119
|
+
export interface CreateLinkOptions {
|
|
120
|
+
/** Template ID (UUID) — required by the API */
|
|
121
|
+
templateId: string;
|
|
122
|
+
/** Template slug — used to construct the full shareable URL */
|
|
123
|
+
templateSlug: string;
|
|
124
|
+
/** Custom parameters embedded in the link (e.g., { route: 'VIDEO_VIEWER', id: '...' }) */
|
|
125
|
+
deepLinkParameters?: Record<string, string>;
|
|
126
|
+
/** Link title (for internal reference) */
|
|
127
|
+
title?: string;
|
|
128
|
+
/** Link description */
|
|
129
|
+
description?: string;
|
|
130
|
+
/** Custom short code (auto-generated if omitted) */
|
|
131
|
+
customCode?: string;
|
|
132
|
+
/** UTM parameters */
|
|
133
|
+
utmParameters?: {
|
|
134
|
+
source?: string;
|
|
135
|
+
medium?: string;
|
|
136
|
+
campaign?: string;
|
|
137
|
+
term?: string;
|
|
138
|
+
content?: string;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Result of creating a short link
|
|
143
|
+
*/
|
|
144
|
+
export interface CreateLinkResult {
|
|
145
|
+
/** Full shareable URL (e.g., 'https://go.example.com/tmpl/abc123') */
|
|
146
|
+
url: string;
|
|
147
|
+
/** The generated short code */
|
|
148
|
+
shortCode: string;
|
|
149
|
+
/** Link UUID */
|
|
150
|
+
linkId: string;
|
|
151
|
+
}
|
|
116
152
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BA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ACnB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,aAAa,CAAC,EAAE;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/package.json
CHANGED
package/src/LinkFortySDK.ts
CHANGED
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
DeepLinkData,
|
|
12
12
|
DeferredDeepLinkCallback,
|
|
13
13
|
DeepLinkCallback,
|
|
14
|
+
CreateLinkOptions,
|
|
15
|
+
CreateLinkResult,
|
|
14
16
|
} from './types';
|
|
15
17
|
|
|
16
18
|
const STORAGE_KEYS = {
|
|
@@ -151,6 +153,73 @@ export class LinkFortySDK {
|
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Create a new short link via the LinkForty API.
|
|
158
|
+
*
|
|
159
|
+
* Requires an API key to be configured in the SDK init options.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const result = await LinkFortySDK.createLink({
|
|
164
|
+
* templateId: 'uuid-of-template',
|
|
165
|
+
* templateSlug: 'ToQs',
|
|
166
|
+
* deepLinkParameters: { route: 'VIDEO_VIEWER', id: 'video-uuid' },
|
|
167
|
+
* title: 'My Video',
|
|
168
|
+
* });
|
|
169
|
+
* // result.url → 'https://go.example.com/ToQs/abc123'
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
async createLink(options: CreateLinkOptions): Promise<CreateLinkResult> {
|
|
173
|
+
if (!this.config) {
|
|
174
|
+
throw new Error('SDK not initialized. Call init() first.');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!this.config.apiKey) {
|
|
178
|
+
throw new Error('API key required to create links. Pass apiKey in init().');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const body: Record<string, unknown> = {
|
|
182
|
+
templateId: options.templateId,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
if (options.deepLinkParameters) {
|
|
186
|
+
body.deepLinkParameters = options.deepLinkParameters;
|
|
187
|
+
}
|
|
188
|
+
if (options.title) {
|
|
189
|
+
body.title = options.title;
|
|
190
|
+
}
|
|
191
|
+
if (options.description) {
|
|
192
|
+
body.description = options.description;
|
|
193
|
+
}
|
|
194
|
+
if (options.customCode) {
|
|
195
|
+
body.customCode = options.customCode;
|
|
196
|
+
}
|
|
197
|
+
if (options.utmParameters) {
|
|
198
|
+
body.utmParameters = options.utmParameters;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const response = await this.apiRequest<{ id: string; short_code: string }>(
|
|
202
|
+
'/api/links',
|
|
203
|
+
{
|
|
204
|
+
method: 'POST',
|
|
205
|
+
body: JSON.stringify(body),
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const shortCode = response.short_code;
|
|
210
|
+
const url = `${this.config.baseUrl}/${options.templateSlug}/${shortCode}`;
|
|
211
|
+
|
|
212
|
+
if (this.config.debug) {
|
|
213
|
+
console.log('[LinkForty] Created link:', url);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
url,
|
|
218
|
+
shortCode,
|
|
219
|
+
linkId: response.id,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
154
223
|
/**
|
|
155
224
|
* Get install ID
|
|
156
225
|
*/
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -121,3 +121,41 @@ export type DeepLinkCallback = (url: string, deepLinkData: DeepLinkData | null)
|
|
|
121
121
|
* before the server can process the redirect.
|
|
122
122
|
*/
|
|
123
123
|
export type ResolveFunction = (path: string) => Promise<DeepLinkData | null>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Options for creating a new short link via the LinkForty API
|
|
127
|
+
*/
|
|
128
|
+
export interface CreateLinkOptions {
|
|
129
|
+
/** Template ID (UUID) — required by the API */
|
|
130
|
+
templateId: string;
|
|
131
|
+
/** Template slug — used to construct the full shareable URL */
|
|
132
|
+
templateSlug: string;
|
|
133
|
+
/** Custom parameters embedded in the link (e.g., { route: 'VIDEO_VIEWER', id: '...' }) */
|
|
134
|
+
deepLinkParameters?: Record<string, string>;
|
|
135
|
+
/** Link title (for internal reference) */
|
|
136
|
+
title?: string;
|
|
137
|
+
/** Link description */
|
|
138
|
+
description?: string;
|
|
139
|
+
/** Custom short code (auto-generated if omitted) */
|
|
140
|
+
customCode?: string;
|
|
141
|
+
/** UTM parameters */
|
|
142
|
+
utmParameters?: {
|
|
143
|
+
source?: string;
|
|
144
|
+
medium?: string;
|
|
145
|
+
campaign?: string;
|
|
146
|
+
term?: string;
|
|
147
|
+
content?: string;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Result of creating a short link
|
|
153
|
+
*/
|
|
154
|
+
export interface CreateLinkResult {
|
|
155
|
+
/** Full shareable URL (e.g., 'https://go.example.com/tmpl/abc123') */
|
|
156
|
+
url: string;
|
|
157
|
+
/** The generated short code */
|
|
158
|
+
shortCode: string;
|
|
159
|
+
/** Link UUID */
|
|
160
|
+
linkId: string;
|
|
161
|
+
}
|