@quipuscore/watson-core-capacitor 0.1.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.
- package/Package.swift +24 -0
- package/QuipuscoreWatsonCore.podspec +17 -0
- package/android/build.gradle +46 -0
- package/android/settings.gradle +5 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/com/quipuscore/watson/core/CapacitorPermissionRequester.java +63 -0
- package/android/src/main/java/com/quipuscore/watson/core/WatsonCorePlugin.java +156 -0
- package/dist/esm/collector.d.ts +12 -0
- package/dist/esm/collector.d.ts.map +1 -0
- package/dist/esm/collector.js +11 -0
- package/dist/esm/collector.js.map +1 -0
- package/dist/esm/definitions.d.ts +44 -0
- package/dist/esm/definitions.d.ts.map +1 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/plugin.d.ts +7 -0
- package/dist/esm/plugin.d.ts.map +1 -0
- package/dist/esm/plugin.js +9 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/esm/service.d.ts +26 -0
- package/dist/esm/service.d.ts.map +1 -0
- package/dist/esm/service.js +41 -0
- package/dist/esm/service.js.map +1 -0
- package/dist/esm/web.d.ts +9 -0
- package/dist/esm/web.d.ts.map +1 -0
- package/dist/esm/web.js +11 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +82 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +85 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/WatsonCore/WatsonCorePlugin.swift +22 -0
- package/package.json +49 -0
package/Package.swift
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "QuipuscoreWatsonCore",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "QuipuscoreWatsonCore",
|
|
10
|
+
targets: ["WatsonCorePlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "WatsonCorePlugin",
|
|
18
|
+
dependencies: [
|
|
19
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
21
|
+
],
|
|
22
|
+
path: "ios/Sources/WatsonCore")
|
|
23
|
+
]
|
|
24
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'QuipuscoreWatsonCore'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = 'https://github.com/quipucorp/watson-capacitor'
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => 'https://github.com/quipucorp/watson-capacitor.git', :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
3
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
4
|
+
watsonCoreVersion = project.hasProperty('watsonCoreVersion') ? rootProject.ext.watsonCoreVersion : '0.1.0'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
buildscript {
|
|
8
|
+
repositories {
|
|
9
|
+
google()
|
|
10
|
+
mavenCentral()
|
|
11
|
+
}
|
|
12
|
+
dependencies {
|
|
13
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
apply plugin: 'com.android.library'
|
|
18
|
+
|
|
19
|
+
android {
|
|
20
|
+
namespace "com.quipuscore.watson.core"
|
|
21
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
22
|
+
defaultConfig {
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
25
|
+
}
|
|
26
|
+
compileOptions {
|
|
27
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
28
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
29
|
+
}
|
|
30
|
+
lint {
|
|
31
|
+
abortOnError false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
repositories {
|
|
36
|
+
google()
|
|
37
|
+
mavenCentral()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
dependencies {
|
|
41
|
+
implementation project(':capacitor-android')
|
|
42
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
43
|
+
// The Watson core owns all policy: permissions, ledger, compression, aggregation.
|
|
44
|
+
implementation "com.quipuscore:watson-core:$watsonCoreVersion"
|
|
45
|
+
testImplementation "junit:junit:$junitVersion"
|
|
46
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Only used for the standalone plugin build (`cd android && ./gradlew ...`). When the plugin is
|
|
2
|
+
// consumed by an app, Capacitor's generated settings include capacitor-android instead.
|
|
3
|
+
// node_modules is hoisted to the monorepo root by npm workspaces.
|
|
4
|
+
include ':capacitor-android'
|
|
5
|
+
project(':capacitor-android').projectDir = new File('../../../node_modules/@capacitor/android/capacitor')
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<!--
|
|
4
|
+
The core declares no dangerous permissions. Each collector artifact (com.quipuscore:watson-sms,
|
|
5
|
+
etc.) declares its own permission in its manifest, which merges into the app only when that
|
|
6
|
+
collector package is installed. This keeps permission isolation intact.
|
|
7
|
+
-->
|
|
8
|
+
</manifest>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
package com.quipuscore.watson.core;
|
|
2
|
+
|
|
3
|
+
import android.Manifest;
|
|
4
|
+
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
|
|
7
|
+
import com.quipuscore.watson.core.PermissionRequester;
|
|
8
|
+
import com.quipuscore.watson.core.PermissionResultCallback;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.LinkedHashSet;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
import java.util.Set;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The wrapper's only permission code, and it decides nothing. The core hands it the exact list of
|
|
17
|
+
* permissions to prompt for; this adapter maps each to its Capacitor alias, fires the framework's
|
|
18
|
+
* permission flow, and signals completion once the user has responded. The core re-reads the live
|
|
19
|
+
* grant state of each collector when the run resumes, so no results are carried back.
|
|
20
|
+
*
|
|
21
|
+
* <p>Because the core owns the ledger and gating, the native default request code ({@code 8801}) and
|
|
22
|
+
* {@code handlePermissionResult} are not used with this requester — which avoids the fragility of
|
|
23
|
+
* reserved request codes across Capacitor versions.
|
|
24
|
+
*/
|
|
25
|
+
final class CapacitorPermissionRequester implements PermissionRequester {
|
|
26
|
+
|
|
27
|
+
private final WatsonCorePlugin plugin;
|
|
28
|
+
private final PluginCall call;
|
|
29
|
+
|
|
30
|
+
CapacitorPermissionRequester(WatsonCorePlugin plugin, PluginCall call) {
|
|
31
|
+
this.plugin = plugin;
|
|
32
|
+
this.call = call;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public void requestPermissions(List<String> permissions, PermissionResultCallback onComplete) {
|
|
37
|
+
String[] aliases = aliasesFor(permissions);
|
|
38
|
+
if (aliases.length == 0) {
|
|
39
|
+
// Nothing this wrapper knows how to prompt for; let the core proceed and gate per collector.
|
|
40
|
+
onComplete.onPermissionsResolved();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
plugin.promptForAliases(aliases, call, onComplete);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Maps runtime permission strings to the aliases declared in {@link WatsonCorePlugin}. Unknown
|
|
48
|
+
* permissions are dropped (a new collector permission needs a new alias in the plugin).
|
|
49
|
+
*/
|
|
50
|
+
private static String[] aliasesFor(List<String> permissions) {
|
|
51
|
+
Set<String> aliases = new LinkedHashSet<>();
|
|
52
|
+
for (String permission : permissions) {
|
|
53
|
+
if (Manifest.permission.READ_SMS.equals(permission)) {
|
|
54
|
+
aliases.add("sms");
|
|
55
|
+
} else if (Manifest.permission.READ_CALENDAR.equals(permission)) {
|
|
56
|
+
aliases.add("calendar");
|
|
57
|
+
} else if (Manifest.permission.READ_CONTACTS.equals(permission)) {
|
|
58
|
+
aliases.add("contacts");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return new ArrayList<>(aliases).toArray(new String[0]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
package com.quipuscore.watson.core;
|
|
2
|
+
|
|
3
|
+
import android.Manifest;
|
|
4
|
+
|
|
5
|
+
import com.getcapacitor.JSArray;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.Plugin;
|
|
8
|
+
import com.getcapacitor.PluginCall;
|
|
9
|
+
import com.getcapacitor.PluginMethod;
|
|
10
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
11
|
+
import com.getcapacitor.annotation.Permission;
|
|
12
|
+
import com.getcapacitor.annotation.PermissionCallback;
|
|
13
|
+
|
|
14
|
+
import com.quipuscore.watson.core.CollectionCallback;
|
|
15
|
+
import com.quipuscore.watson.core.CollectionResult;
|
|
16
|
+
import com.quipuscore.watson.core.CollectorOutcome;
|
|
17
|
+
import com.quipuscore.watson.core.PermissionResultCallback;
|
|
18
|
+
import com.quipuscore.watson.core.WatsonService;
|
|
19
|
+
|
|
20
|
+
import org.json.JSONException;
|
|
21
|
+
|
|
22
|
+
import java.util.List;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Capacitor bridge for the Watson core. Thin by design: it builds a native {@link WatsonService}
|
|
26
|
+
* from the collector ids sent across the bridge, delegates permission delivery to
|
|
27
|
+
* {@link CapacitorPermissionRequester}, and serializes the {@link CollectionResult} back to JS. It
|
|
28
|
+
* reimplements no policy — the native core decides which permissions to request, keeps the ledger,
|
|
29
|
+
* compresses and aggregates.
|
|
30
|
+
*
|
|
31
|
+
* <p>The permission aliases below are declared even though this module does not depend on the
|
|
32
|
+
* collector modules at compile time: the strings are Android constants, and the dangerous permission
|
|
33
|
+
* reaches the merged manifest through the collector artifact the developer installed. A new collector
|
|
34
|
+
* with a new permission means adding its alias here.
|
|
35
|
+
*/
|
|
36
|
+
@CapacitorPlugin(
|
|
37
|
+
name = "WatsonCore",
|
|
38
|
+
permissions = {
|
|
39
|
+
@Permission(strings = { Manifest.permission.READ_SMS }, alias = "sms"),
|
|
40
|
+
@Permission(strings = { Manifest.permission.READ_CALENDAR }, alias = "calendar"),
|
|
41
|
+
@Permission(strings = { Manifest.permission.READ_CONTACTS }, alias = "contacts"),
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
public class WatsonCorePlugin extends Plugin {
|
|
45
|
+
|
|
46
|
+
/** Held across the async Capacitor permission prompt so the core collection can resume. */
|
|
47
|
+
private PermissionResultCallback pendingPermissionCallback;
|
|
48
|
+
|
|
49
|
+
@PluginMethod
|
|
50
|
+
public void collect(PluginCall call) {
|
|
51
|
+
final WatsonService service;
|
|
52
|
+
try {
|
|
53
|
+
service = buildService(call);
|
|
54
|
+
} catch (JSONException e) {
|
|
55
|
+
call.reject("Invalid 'collectors' argument", e);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
service.collect(new CollectionCallback() {
|
|
60
|
+
@Override
|
|
61
|
+
public void onSuccess(CollectionResult result) {
|
|
62
|
+
call.resolve(toJs(result));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Override
|
|
66
|
+
public void onError(Exception error) {
|
|
67
|
+
call.reject(error.getMessage(), error);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@PluginMethod
|
|
73
|
+
public void getUngrantedPermissions(PluginCall call) {
|
|
74
|
+
final WatsonService service;
|
|
75
|
+
try {
|
|
76
|
+
service = buildService(call);
|
|
77
|
+
} catch (JSONException e) {
|
|
78
|
+
call.reject("Invalid 'collectors' argument", e);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
JSArray permissions = new JSArray();
|
|
83
|
+
for (String permission : service.getUngrantedPermissions()) {
|
|
84
|
+
permissions.put(permission);
|
|
85
|
+
}
|
|
86
|
+
JSObject ret = new JSObject();
|
|
87
|
+
ret.put("permissions", permissions);
|
|
88
|
+
call.resolve(ret);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Builds the native service from the ids sent across the bridge. Built here (not in
|
|
93
|
+
* {@link #load()}) so every collector plugin has already registered its factory in the core's
|
|
94
|
+
* registry by the time collection runs.
|
|
95
|
+
*/
|
|
96
|
+
private WatsonService buildService(PluginCall call) throws JSONException {
|
|
97
|
+
WatsonService.Builder builder = new WatsonService.Builder(getContext());
|
|
98
|
+
JSArray ids = call.getArray("collectors", new JSArray());
|
|
99
|
+
List<String> idList = ids.toList();
|
|
100
|
+
for (String id : idList) {
|
|
101
|
+
// Resolves via the core's WatsonRegistry; throws if the matching module is not installed.
|
|
102
|
+
builder.addCollector(id);
|
|
103
|
+
}
|
|
104
|
+
WatsonService service = builder
|
|
105
|
+
.permissionRequester(new CapacitorPermissionRequester(this, call))
|
|
106
|
+
.build();
|
|
107
|
+
// The ledger still uses the Activity to tell a temporary denial from a permanent one.
|
|
108
|
+
service.setActivity(getActivity());
|
|
109
|
+
return service;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Fires the Capacitor permission prompt for {@code aliases} and remembers {@code onComplete} so
|
|
114
|
+
* {@link #handleWatsonPermissions(PluginCall)} can resume the parked collection. Called only by
|
|
115
|
+
* {@link CapacitorPermissionRequester}.
|
|
116
|
+
*/
|
|
117
|
+
void promptForAliases(String[] aliases, PluginCall call, PermissionResultCallback onComplete) {
|
|
118
|
+
this.pendingPermissionCallback = onComplete;
|
|
119
|
+
requestPermissionForAliases(aliases, call, "handleWatsonPermissions");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@PermissionCallback
|
|
123
|
+
private void handleWatsonPermissions(PluginCall call) {
|
|
124
|
+
PermissionResultCallback callback = this.pendingPermissionCallback;
|
|
125
|
+
this.pendingPermissionCallback = null;
|
|
126
|
+
if (callback != null) {
|
|
127
|
+
// The core re-reads live grant state per collector; no results are carried back here.
|
|
128
|
+
callback.onPermissionsResolved();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private JSObject toJs(CollectionResult result) {
|
|
133
|
+
JSObject res = new JSObject();
|
|
134
|
+
res.put("data", result.getData());
|
|
135
|
+
res.put("submissionId", result.getSubmissionId());
|
|
136
|
+
res.put("isComplete", result.isComplete());
|
|
137
|
+
|
|
138
|
+
JSArray outcomes = new JSArray();
|
|
139
|
+
for (CollectorOutcome outcome : result.getOutcomes()) {
|
|
140
|
+
JSObject o = new JSObject();
|
|
141
|
+
o.put("collectorId", outcome.getCollectorId());
|
|
142
|
+
o.put("status", outcome.getStatus().name());
|
|
143
|
+
if (outcome.getErrorMessage() != null) {
|
|
144
|
+
o.put("errorMessage", outcome.getErrorMessage());
|
|
145
|
+
}
|
|
146
|
+
JSArray missing = new JSArray();
|
|
147
|
+
for (String permission : outcome.getMissingPermissions()) {
|
|
148
|
+
missing.put(permission);
|
|
149
|
+
}
|
|
150
|
+
o.put("missingPermissions", missing);
|
|
151
|
+
outcomes.put(o);
|
|
152
|
+
}
|
|
153
|
+
res.put("outcomes", outcomes);
|
|
154
|
+
return res;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base type for a collector descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Collector packages (for example `@quipuscore/watson-sms-capacitor`) extend this with the stable `id` their
|
|
5
|
+
* native module registered with the Watson core. A descriptor carries no logic: it only tells the
|
|
6
|
+
* core, across the bridge, which registered collector to run. This mirrors the explicit-registration
|
|
7
|
+
* model of the native SDK — a collector you never add is never collected.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class WatsonCollector {
|
|
10
|
+
abstract readonly id: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAAsB,eAAe;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base type for a collector descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Collector packages (for example `@quipuscore/watson-sms-capacitor`) extend this with the stable `id` their
|
|
5
|
+
* native module registered with the Watson core. A descriptor carries no logic: it only tells the
|
|
6
|
+
* core, across the bridge, which registered collector to run. This mirrors the explicit-registration
|
|
7
|
+
* model of the native SDK — a collector you never add is never collected.
|
|
8
|
+
*/
|
|
9
|
+
export class WatsonCollector {
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAgB,eAAe;CAEpC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type CollectorStatus = 'SUCCESS' | 'PERMISSION_DENIED' | 'PERMISSION_PERMANENTLY_DENIED' | 'ERROR';
|
|
2
|
+
/** Per-collector result of a collection run. Mirrors the native `CollectorOutcome`. */
|
|
3
|
+
export interface CollectorOutcome {
|
|
4
|
+
collectorId: string;
|
|
5
|
+
status: CollectorStatus;
|
|
6
|
+
/** Failure detail when `status === 'ERROR'`; otherwise absent. */
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The ungranted runtime permissions that gated this collector. Non-empty only for the two
|
|
10
|
+
* `PERMISSION_*` statuses; empty otherwise.
|
|
11
|
+
*/
|
|
12
|
+
missingPermissions: string[];
|
|
13
|
+
}
|
|
14
|
+
/** Result of a collection run. Mirrors the native `CollectionResult`. */
|
|
15
|
+
export interface CollectionResult {
|
|
16
|
+
/**
|
|
17
|
+
* The aggregated payload, `base64(gzip(json))`. Send it verbatim to your backend; never
|
|
18
|
+
* decompress it on the device — that is the backend's job.
|
|
19
|
+
*/
|
|
20
|
+
data: string;
|
|
21
|
+
/** Stable, idempotent id `<deviceId>-<collectedAt>`; also embedded inside the payload. */
|
|
22
|
+
submissionId: string;
|
|
23
|
+
/** True only if every collector ran successfully; false on any skipped or failed collector. */
|
|
24
|
+
isComplete: boolean;
|
|
25
|
+
/** Per-collector outcomes, including the ones that were skipped or failed. */
|
|
26
|
+
outcomes: CollectorOutcome[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Low-level bridge contract for the native `WatsonCore` plugin. Application code should use the
|
|
30
|
+
* {@link WatsonService} class instead of calling this plugin directly.
|
|
31
|
+
*/
|
|
32
|
+
export interface WatsonCorePlugin {
|
|
33
|
+
/** Runs the given collector ids natively and returns the compressed payload plus outcomes. */
|
|
34
|
+
collect(options: {
|
|
35
|
+
collectors: string[];
|
|
36
|
+
}): Promise<CollectionResult>;
|
|
37
|
+
/** The runtime permissions required by the given collector ids that are not granted yet. */
|
|
38
|
+
getUngrantedPermissions(options: {
|
|
39
|
+
collectors: string[];
|
|
40
|
+
}): Promise<{
|
|
41
|
+
permissions: string[];
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,mBAAmB,GACnB,+BAA+B,GAC/B,OAAO,CAAC;AAEZ,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;IACxB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,yEAAyE;AACzE,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,0FAA0F;IAC1F,YAAY,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,UAAU,EAAE,OAAO,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8FAA8F;IAC9F,OAAO,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtE,4FAA4F;IAC5F,uBAAuB,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CAChG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WatsonCorePlugin } from './definitions';
|
|
2
|
+
/**
|
|
3
|
+
* The registered native `WatsonCore` plugin proxy. Exposed for advanced use; prefer the
|
|
4
|
+
* {@link WatsonService} class, which mirrors the native API surface.
|
|
5
|
+
*/
|
|
6
|
+
export declare const WatsonCore: WatsonCorePlugin;
|
|
7
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,UAAU,kBAErB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* The registered native `WatsonCore` plugin proxy. Exposed for advanced use; prefer the
|
|
4
|
+
* {@link WatsonService} class, which mirrors the native API surface.
|
|
5
|
+
*/
|
|
6
|
+
export const WatsonCore = registerPlugin('WatsonCore', {
|
|
7
|
+
web: () => import('./web').then(m => new m.WatsonCoreWeb()),
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IACvE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC5D,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WatsonCollector } from './collector';
|
|
2
|
+
import type { CollectionResult } from './definitions';
|
|
3
|
+
/**
|
|
4
|
+
* JS-side orchestrator, mirroring the native `WatsonService`. It accumulates the ids of the
|
|
5
|
+
* collectors you add and hands that list to the native `WatsonCore` plugin on {@link collect}.
|
|
6
|
+
*
|
|
7
|
+
* The always-on `device` baseline is added by the native core itself; you never add it here. The
|
|
8
|
+
* single structural asymmetry with the native API is that `new WatsonService()` takes no `context`
|
|
9
|
+
* — the native plugin injects it.
|
|
10
|
+
*/
|
|
11
|
+
export declare class WatsonService {
|
|
12
|
+
private readonly collectorIds;
|
|
13
|
+
/**
|
|
14
|
+
* Registers a collector to run. Explicit by design: a collector you don't add is not collected
|
|
15
|
+
* and does not pull its runtime permission. Adding the same id twice is a no-op.
|
|
16
|
+
*/
|
|
17
|
+
addCollector(collector: WatsonCollector): void;
|
|
18
|
+
/**
|
|
19
|
+
* Runs every added collector natively and resolves with the compressed payload and the
|
|
20
|
+
* per-collector outcomes. A denied or failing collector never aborts the others.
|
|
21
|
+
*/
|
|
22
|
+
collect(): Promise<CollectionResult>;
|
|
23
|
+
/** The runtime permissions required by the added collectors that are not granted yet. */
|
|
24
|
+
getUngrantedPermissions(): Promise<string[]>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;IAE7C;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAS9C;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIpC,yFAAyF;IACnF,uBAAuB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAMnD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { WatsonCore } from './plugin';
|
|
2
|
+
/**
|
|
3
|
+
* JS-side orchestrator, mirroring the native `WatsonService`. It accumulates the ids of the
|
|
4
|
+
* collectors you add and hands that list to the native `WatsonCore` plugin on {@link collect}.
|
|
5
|
+
*
|
|
6
|
+
* The always-on `device` baseline is added by the native core itself; you never add it here. The
|
|
7
|
+
* single structural asymmetry with the native API is that `new WatsonService()` takes no `context`
|
|
8
|
+
* — the native plugin injects it.
|
|
9
|
+
*/
|
|
10
|
+
export class WatsonService {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.collectorIds = [];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Registers a collector to run. Explicit by design: a collector you don't add is not collected
|
|
16
|
+
* and does not pull its runtime permission. Adding the same id twice is a no-op.
|
|
17
|
+
*/
|
|
18
|
+
addCollector(collector) {
|
|
19
|
+
if (!collector || !collector.id) {
|
|
20
|
+
throw new Error('addCollector requires a collector with a non-empty id');
|
|
21
|
+
}
|
|
22
|
+
if (this.collectorIds.indexOf(collector.id) === -1) {
|
|
23
|
+
this.collectorIds.push(collector.id);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Runs every added collector natively and resolves with the compressed payload and the
|
|
28
|
+
* per-collector outcomes. A denied or failing collector never aborts the others.
|
|
29
|
+
*/
|
|
30
|
+
collect() {
|
|
31
|
+
return WatsonCore.collect({ collectors: this.collectorIds });
|
|
32
|
+
}
|
|
33
|
+
/** The runtime permissions required by the added collectors that are not granted yet. */
|
|
34
|
+
async getUngrantedPermissions() {
|
|
35
|
+
const { permissions } = await WatsonCore.getUngrantedPermissions({
|
|
36
|
+
collectors: this.collectorIds,
|
|
37
|
+
});
|
|
38
|
+
return permissions;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAA1B;QACmB,iBAAY,GAAa,EAAE,CAAC;IA8B/C,CAAC;IA5BC;;;OAGG;IACH,YAAY,CAAC,SAA0B;QACrC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,UAAU,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,yFAAyF;IACzF,KAAK,CAAC,uBAAuB;QAC3B,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,UAAU,CAAC,uBAAuB,CAAC;YAC/D,UAAU,EAAE,IAAI,CAAC,YAAY;SAC9B,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { CollectionResult, WatsonCorePlugin } from './definitions';
|
|
3
|
+
export declare class WatsonCoreWeb extends WebPlugin implements WatsonCorePlugin {
|
|
4
|
+
collect(): Promise<CollectionResult>;
|
|
5
|
+
getUngrantedPermissions(): Promise<{
|
|
6
|
+
permissions: string[];
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAIxE,qBAAa,aAAc,SAAQ,SAAU,YAAW,gBAAgB;IAChE,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIpC,uBAAuB,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAGpE"}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
const MESSAGE = 'Watson is only available on Android and iOS.';
|
|
3
|
+
export class WatsonCoreWeb extends WebPlugin {
|
|
4
|
+
async collect() {
|
|
5
|
+
throw this.unimplemented(MESSAGE);
|
|
6
|
+
}
|
|
7
|
+
async getUngrantedPermissions() {
|
|
8
|
+
throw this.unimplemented(MESSAGE);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,GAAG,8CAA8C,CAAC;AAE/D,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base type for a collector descriptor.
|
|
7
|
+
*
|
|
8
|
+
* Collector packages (for example `@quipuscore/watson-sms-capacitor`) extend this with the stable `id` their
|
|
9
|
+
* native module registered with the Watson core. A descriptor carries no logic: it only tells the
|
|
10
|
+
* core, across the bridge, which registered collector to run. This mirrors the explicit-registration
|
|
11
|
+
* model of the native SDK — a collector you never add is never collected.
|
|
12
|
+
*/
|
|
13
|
+
class WatsonCollector {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The registered native `WatsonCore` plugin proxy. Exposed for advanced use; prefer the
|
|
18
|
+
* {@link WatsonService} class, which mirrors the native API surface.
|
|
19
|
+
*/
|
|
20
|
+
const WatsonCore = core.registerPlugin('WatsonCore', {
|
|
21
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.WatsonCoreWeb()),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* JS-side orchestrator, mirroring the native `WatsonService`. It accumulates the ids of the
|
|
26
|
+
* collectors you add and hands that list to the native `WatsonCore` plugin on {@link collect}.
|
|
27
|
+
*
|
|
28
|
+
* The always-on `device` baseline is added by the native core itself; you never add it here. The
|
|
29
|
+
* single structural asymmetry with the native API is that `new WatsonService()` takes no `context`
|
|
30
|
+
* — the native plugin injects it.
|
|
31
|
+
*/
|
|
32
|
+
class WatsonService {
|
|
33
|
+
constructor() {
|
|
34
|
+
this.collectorIds = [];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Registers a collector to run. Explicit by design: a collector you don't add is not collected
|
|
38
|
+
* and does not pull its runtime permission. Adding the same id twice is a no-op.
|
|
39
|
+
*/
|
|
40
|
+
addCollector(collector) {
|
|
41
|
+
if (!collector || !collector.id) {
|
|
42
|
+
throw new Error('addCollector requires a collector with a non-empty id');
|
|
43
|
+
}
|
|
44
|
+
if (this.collectorIds.indexOf(collector.id) === -1) {
|
|
45
|
+
this.collectorIds.push(collector.id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Runs every added collector natively and resolves with the compressed payload and the
|
|
50
|
+
* per-collector outcomes. A denied or failing collector never aborts the others.
|
|
51
|
+
*/
|
|
52
|
+
collect() {
|
|
53
|
+
return WatsonCore.collect({ collectors: this.collectorIds });
|
|
54
|
+
}
|
|
55
|
+
/** The runtime permissions required by the added collectors that are not granted yet. */
|
|
56
|
+
async getUngrantedPermissions() {
|
|
57
|
+
const { permissions } = await WatsonCore.getUngrantedPermissions({
|
|
58
|
+
collectors: this.collectorIds,
|
|
59
|
+
});
|
|
60
|
+
return permissions;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const MESSAGE = 'Watson is only available on Android and iOS.';
|
|
65
|
+
class WatsonCoreWeb extends core.WebPlugin {
|
|
66
|
+
async collect() {
|
|
67
|
+
throw this.unimplemented(MESSAGE);
|
|
68
|
+
}
|
|
69
|
+
async getUngrantedPermissions() {
|
|
70
|
+
throw this.unimplemented(MESSAGE);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
75
|
+
__proto__: null,
|
|
76
|
+
WatsonCoreWeb: WatsonCoreWeb
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
exports.WatsonCollector = WatsonCollector;
|
|
80
|
+
exports.WatsonCore = WatsonCore;
|
|
81
|
+
exports.WatsonService = WatsonService;
|
|
82
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/collector.js","esm/plugin.js","esm/service.js","esm/web.js"],"sourcesContent":["/**\n * Base type for a collector descriptor.\n *\n * Collector packages (for example `@quipuscore/watson-sms-capacitor`) extend this with the stable `id` their\n * native module registered with the Watson core. A descriptor carries no logic: it only tells the\n * core, across the bridge, which registered collector to run. This mirrors the explicit-registration\n * model of the native SDK — a collector you never add is never collected.\n */\nexport class WatsonCollector {\n}\n//# sourceMappingURL=collector.js.map","import { registerPlugin } from '@capacitor/core';\n/**\n * The registered native `WatsonCore` plugin proxy. Exposed for advanced use; prefer the\n * {@link WatsonService} class, which mirrors the native API surface.\n */\nexport const WatsonCore = registerPlugin('WatsonCore', {\n web: () => import('./web').then(m => new m.WatsonCoreWeb()),\n});\n//# sourceMappingURL=plugin.js.map","import { WatsonCore } from './plugin';\n/**\n * JS-side orchestrator, mirroring the native `WatsonService`. It accumulates the ids of the\n * collectors you add and hands that list to the native `WatsonCore` plugin on {@link collect}.\n *\n * The always-on `device` baseline is added by the native core itself; you never add it here. The\n * single structural asymmetry with the native API is that `new WatsonService()` takes no `context`\n * — the native plugin injects it.\n */\nexport class WatsonService {\n constructor() {\n this.collectorIds = [];\n }\n /**\n * Registers a collector to run. Explicit by design: a collector you don't add is not collected\n * and does not pull its runtime permission. Adding the same id twice is a no-op.\n */\n addCollector(collector) {\n if (!collector || !collector.id) {\n throw new Error('addCollector requires a collector with a non-empty id');\n }\n if (this.collectorIds.indexOf(collector.id) === -1) {\n this.collectorIds.push(collector.id);\n }\n }\n /**\n * Runs every added collector natively and resolves with the compressed payload and the\n * per-collector outcomes. A denied or failing collector never aborts the others.\n */\n collect() {\n return WatsonCore.collect({ collectors: this.collectorIds });\n }\n /** The runtime permissions required by the added collectors that are not granted yet. */\n async getUngrantedPermissions() {\n const { permissions } = await WatsonCore.getUngrantedPermissions({\n collectors: this.collectorIds,\n });\n return permissions;\n }\n}\n//# sourceMappingURL=service.js.map","import { WebPlugin } from '@capacitor/core';\nconst MESSAGE = 'Watson is only available on Android and iOS.';\nexport class WatsonCoreWeb extends WebPlugin {\n async collect() {\n throw this.unimplemented(MESSAGE);\n }\n async getUngrantedPermissions() {\n throw this.unimplemented(MESSAGE);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,eAAe,CAAC;AAC7B;;ACRA;AACA;AACA;AACA;AACY,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AACvD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACND;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAa,CAAC;AAC3B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;AAC9B,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI,YAAY,CAAC,SAAS,EAAE;AAC5B,QAAQ,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE;AACzC,YAAY,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC;AACpF,QAAQ;AACR,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;AAC5D,YAAY,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;AAChD,QAAQ;AACR,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI,OAAO,GAAG;AACd,QAAQ,OAAO,UAAU,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;AACpE,IAAI;AACJ;AACA,IAAI,MAAM,uBAAuB,GAAG;AACpC,QAAQ,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,UAAU,CAAC,uBAAuB,CAAC;AACzE,YAAY,UAAU,EAAE,IAAI,CAAC,YAAY;AACzC,SAAS,CAAC;AACV,QAAQ,OAAO,WAAW;AAC1B,IAAI;AACJ;;ACtCA,MAAM,OAAO,GAAG,8CAA8C;AACvD,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;AACzC,IAAI;AACJ,IAAI,MAAM,uBAAuB,GAAG;AACpC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;AACzC,IAAI;AACJ;;;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var capacitorWatsonCore = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base type for a collector descriptor.
|
|
6
|
+
*
|
|
7
|
+
* Collector packages (for example `@quipuscore/watson-sms-capacitor`) extend this with the stable `id` their
|
|
8
|
+
* native module registered with the Watson core. A descriptor carries no logic: it only tells the
|
|
9
|
+
* core, across the bridge, which registered collector to run. This mirrors the explicit-registration
|
|
10
|
+
* model of the native SDK — a collector you never add is never collected.
|
|
11
|
+
*/
|
|
12
|
+
class WatsonCollector {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The registered native `WatsonCore` plugin proxy. Exposed for advanced use; prefer the
|
|
17
|
+
* {@link WatsonService} class, which mirrors the native API surface.
|
|
18
|
+
*/
|
|
19
|
+
const WatsonCore = core.registerPlugin('WatsonCore', {
|
|
20
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.WatsonCoreWeb()),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* JS-side orchestrator, mirroring the native `WatsonService`. It accumulates the ids of the
|
|
25
|
+
* collectors you add and hands that list to the native `WatsonCore` plugin on {@link collect}.
|
|
26
|
+
*
|
|
27
|
+
* The always-on `device` baseline is added by the native core itself; you never add it here. The
|
|
28
|
+
* single structural asymmetry with the native API is that `new WatsonService()` takes no `context`
|
|
29
|
+
* — the native plugin injects it.
|
|
30
|
+
*/
|
|
31
|
+
class WatsonService {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.collectorIds = [];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Registers a collector to run. Explicit by design: a collector you don't add is not collected
|
|
37
|
+
* and does not pull its runtime permission. Adding the same id twice is a no-op.
|
|
38
|
+
*/
|
|
39
|
+
addCollector(collector) {
|
|
40
|
+
if (!collector || !collector.id) {
|
|
41
|
+
throw new Error('addCollector requires a collector with a non-empty id');
|
|
42
|
+
}
|
|
43
|
+
if (this.collectorIds.indexOf(collector.id) === -1) {
|
|
44
|
+
this.collectorIds.push(collector.id);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Runs every added collector natively and resolves with the compressed payload and the
|
|
49
|
+
* per-collector outcomes. A denied or failing collector never aborts the others.
|
|
50
|
+
*/
|
|
51
|
+
collect() {
|
|
52
|
+
return WatsonCore.collect({ collectors: this.collectorIds });
|
|
53
|
+
}
|
|
54
|
+
/** The runtime permissions required by the added collectors that are not granted yet. */
|
|
55
|
+
async getUngrantedPermissions() {
|
|
56
|
+
const { permissions } = await WatsonCore.getUngrantedPermissions({
|
|
57
|
+
collectors: this.collectorIds,
|
|
58
|
+
});
|
|
59
|
+
return permissions;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const MESSAGE = 'Watson is only available on Android and iOS.';
|
|
64
|
+
class WatsonCoreWeb extends core.WebPlugin {
|
|
65
|
+
async collect() {
|
|
66
|
+
throw this.unimplemented(MESSAGE);
|
|
67
|
+
}
|
|
68
|
+
async getUngrantedPermissions() {
|
|
69
|
+
throw this.unimplemented(MESSAGE);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
74
|
+
__proto__: null,
|
|
75
|
+
WatsonCoreWeb: WatsonCoreWeb
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
exports.WatsonCollector = WatsonCollector;
|
|
79
|
+
exports.WatsonCore = WatsonCore;
|
|
80
|
+
exports.WatsonService = WatsonService;
|
|
81
|
+
|
|
82
|
+
return exports;
|
|
83
|
+
|
|
84
|
+
})({}, capacitorExports);
|
|
85
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/collector.js","esm/plugin.js","esm/service.js","esm/web.js"],"sourcesContent":["/**\n * Base type for a collector descriptor.\n *\n * Collector packages (for example `@quipuscore/watson-sms-capacitor`) extend this with the stable `id` their\n * native module registered with the Watson core. A descriptor carries no logic: it only tells the\n * core, across the bridge, which registered collector to run. This mirrors the explicit-registration\n * model of the native SDK — a collector you never add is never collected.\n */\nexport class WatsonCollector {\n}\n//# sourceMappingURL=collector.js.map","import { registerPlugin } from '@capacitor/core';\n/**\n * The registered native `WatsonCore` plugin proxy. Exposed for advanced use; prefer the\n * {@link WatsonService} class, which mirrors the native API surface.\n */\nexport const WatsonCore = registerPlugin('WatsonCore', {\n web: () => import('./web').then(m => new m.WatsonCoreWeb()),\n});\n//# sourceMappingURL=plugin.js.map","import { WatsonCore } from './plugin';\n/**\n * JS-side orchestrator, mirroring the native `WatsonService`. It accumulates the ids of the\n * collectors you add and hands that list to the native `WatsonCore` plugin on {@link collect}.\n *\n * The always-on `device` baseline is added by the native core itself; you never add it here. The\n * single structural asymmetry with the native API is that `new WatsonService()` takes no `context`\n * — the native plugin injects it.\n */\nexport class WatsonService {\n constructor() {\n this.collectorIds = [];\n }\n /**\n * Registers a collector to run. Explicit by design: a collector you don't add is not collected\n * and does not pull its runtime permission. Adding the same id twice is a no-op.\n */\n addCollector(collector) {\n if (!collector || !collector.id) {\n throw new Error('addCollector requires a collector with a non-empty id');\n }\n if (this.collectorIds.indexOf(collector.id) === -1) {\n this.collectorIds.push(collector.id);\n }\n }\n /**\n * Runs every added collector natively and resolves with the compressed payload and the\n * per-collector outcomes. A denied or failing collector never aborts the others.\n */\n collect() {\n return WatsonCore.collect({ collectors: this.collectorIds });\n }\n /** The runtime permissions required by the added collectors that are not granted yet. */\n async getUngrantedPermissions() {\n const { permissions } = await WatsonCore.getUngrantedPermissions({\n collectors: this.collectorIds,\n });\n return permissions;\n }\n}\n//# sourceMappingURL=service.js.map","import { WebPlugin } from '@capacitor/core';\nconst MESSAGE = 'Watson is only available on Android and iOS.';\nexport class WatsonCoreWeb extends WebPlugin {\n async collect() {\n throw this.unimplemented(MESSAGE);\n }\n async getUngrantedPermissions() {\n throw this.unimplemented(MESSAGE);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACO,MAAM,eAAe,CAAC;IAC7B;;ICRA;IACA;IACA;IACA;AACY,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IACvD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IAC/D,CAAC;;ICND;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACO,MAAM,aAAa,CAAC;IAC3B,IAAI,WAAW,GAAG;IAClB,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE;IAC9B,IAAI;IACJ;IACA;IACA;IACA;IACA,IAAI,YAAY,CAAC,SAAS,EAAE;IAC5B,QAAQ,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE;IACzC,YAAY,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC;IACpF,QAAQ;IACR,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;IAC5D,YAAY,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;IAChD,QAAQ;IACR,IAAI;IACJ;IACA;IACA;IACA;IACA,IAAI,OAAO,GAAG;IACd,QAAQ,OAAO,UAAU,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;IACpE,IAAI;IACJ;IACA,IAAI,MAAM,uBAAuB,GAAG;IACpC,QAAQ,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,UAAU,CAAC,uBAAuB,CAAC;IACzE,YAAY,UAAU,EAAE,IAAI,CAAC,YAAY;IACzC,SAAS,CAAC;IACV,QAAQ,OAAO,WAAW;IAC1B,IAAI;IACJ;;ICtCA,MAAM,OAAO,GAAG,8CAA8C;IACvD,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACzC,IAAI;IACJ,IAAI,MAAM,uBAAuB,GAAG;IACpC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;IACzC,IAAI;IACJ;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
|
|
3
|
+
/// iOS stub. The Watson iOS base (`watson_ios`) does not exist yet, so this plugin is present only
|
|
4
|
+
/// to keep the package structure iOS-ready. When `watson_ios` lands, implement these methods against
|
|
5
|
+
/// it while preserving the TypeScript contract in `src/` unchanged.
|
|
6
|
+
@objc(WatsonCorePlugin)
|
|
7
|
+
public class WatsonCorePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
8
|
+
public let identifier = "WatsonCorePlugin"
|
|
9
|
+
public let jsName = "WatsonCore"
|
|
10
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
11
|
+
CAPPluginMethod(name: "collect", returnType: CAPPluginReturnPromise),
|
|
12
|
+
CAPPluginMethod(name: "getUngrantedPermissions", returnType: CAPPluginReturnPromise),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
@objc func collect(_ call: CAPPluginCall) {
|
|
16
|
+
call.unimplemented("The Watson iOS base is not available yet.")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@objc func getUngrantedPermissions(_ call: CAPPluginCall) {
|
|
20
|
+
call.unimplemented("The Watson iOS base is not available yet.")
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quipuscore/watson-core-capacitor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Capacitor wrapper for the Watson core SDK: orchestrator + always-on device baseline.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"main": "dist/plugin.cjs.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"types": "dist/esm/index.d.ts",
|
|
9
|
+
"unpkg": "dist/plugin.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"android/src/main/",
|
|
12
|
+
"android/build.gradle",
|
|
13
|
+
"android/settings.gradle",
|
|
14
|
+
"dist/",
|
|
15
|
+
"ios/Sources/",
|
|
16
|
+
"Package.swift",
|
|
17
|
+
"QuipuscoreWatsonCore.podspec"
|
|
18
|
+
],
|
|
19
|
+
"author": "Quipu",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"capacitor",
|
|
22
|
+
"plugin",
|
|
23
|
+
"native",
|
|
24
|
+
"watson"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm run clean && tsc && rollup -c rollup.config.js",
|
|
28
|
+
"clean": "rimraf ./dist",
|
|
29
|
+
"watch": "tsc --watch",
|
|
30
|
+
"verify:web": "npm run build",
|
|
31
|
+
"verify:android": "cd android && ./gradlew clean build test",
|
|
32
|
+
"capacitor": "cap"
|
|
33
|
+
},
|
|
34
|
+
"capacitor": {
|
|
35
|
+
"android": {
|
|
36
|
+
"src": "android"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@capacitor/android": "^7.0.0",
|
|
41
|
+
"@capacitor/core": "^7.0.0",
|
|
42
|
+
"rimraf": "^5.0.5",
|
|
43
|
+
"rollup": "^4.9.0",
|
|
44
|
+
"typescript": "^5.4.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@capacitor/core": "^7.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|